Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update/rebase against upstream #37

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions lib/romeo/connection.ex
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ defmodule Romeo.Connection do
args
|> Keyword.put_new(:timeout, @timeout)
|> Keyword.put_new(:transport, @default_transport)
|> Keyword.put(:owner, self())
|> Keyword.put_new(:owner, self())

Connection.start_link(__MODULE__, struct(__MODULE__, args), options)
end
Expand All @@ -75,7 +75,7 @@ defmodule Romeo.Connection do

* `:timeout` - Call timeout (default: `#{@timeout}`)
"""
@spec close(pid, Keyword.t) :: :ok
@spec close(pid, Keyword.t()) :: :ok
def close(pid, opts \\ []) do
Connection.call(pid, :close, opts[:timeout] || @timeout)
end
Expand All @@ -90,11 +90,17 @@ defmodule Romeo.Connection do
case transport.connect(conn) do
{:ok, conn} ->
{:ok, conn}

{:error, _} ->
{:backoff, timeout, conn}
end
end

def disconnect({:close, from}, %{socket: socket, transport: transport} = conn) do
transport.disconnect({:close, from}, socket)
{:stop, {:shutdown, :closed}, conn}
end

def disconnect(info, %{socket: socket, transport: transport} = conn) do
transport.disconnect(info, socket)
{:connect, :reconnect, reset_connection(conn)}
Expand All @@ -107,14 +113,17 @@ defmodule Romeo.Connection do
def handle_call(_, _, %{socket: nil} = conn) do
{:reply, {:error, :closed}, conn}
end

def handle_call({:send, data}, _, %{transport: transport} = conn) do
case transport.send(conn, data) do
{:ok, conn} ->
{:reply, :ok, conn}

{:error, _} = error ->
{:disconnect, error, error, conn}
end
end

def handle_call(:close, from, %{socket: socket, transport: transport} = conn) do
transport.disconnect({:close, from}, socket)
{:reply, :ok, conn}
Expand All @@ -124,16 +133,20 @@ defmodule Romeo.Connection do
case transport.handle_message(info, conn) do
{:ok, conn, :more} ->
{:noreply, conn}

{:ok, conn, stanza} ->
stanza = Romeo.Stanza.Parser.parse(stanza)
Kernel.send(owner, {:stanza, stanza})
Kernel.send(owner, {:stanza, stanza, self()})
{:noreply, conn}

{:error, _} = error ->
{:disconnect, error, conn}

:unknown ->
Logger.debug fn ->
Logger.debug(fn ->
[inspect(__MODULE__), ?\s, inspect(self()), " received message: " | inspect(info)]
end
end)

{:noreply, conn}
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/romeo/stanza.ex
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,15 @@ defmodule Romeo.Stanza do
def auth(mechanism, [], []) do
xmlel(name: "auth",
attrs: [
{"xmlns", ns_sasl},
{"xmlns", ns_sasl()},
{"mechanism", mechanism},
],
children: [])
end
def auth(mechanism, body, []) do
xmlel(name: "auth",
attrs: [
{"xmlns", ns_sasl},
{"xmlns", ns_sasl()},
{"mechanism", mechanism},
],
children: [body])
Expand Down
56 changes: 30 additions & 26 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -4,53 +4,57 @@ defmodule Romeo.Mixfile do
@version "0.7.0"

def project do
[app: :romeo,
name: "Romeo",
version: @version,
elixir: "~> 1.1",
build_embedded: Mix.env == :prod,
start_permanent: Mix.env == :prod,
description: description(),
deps: deps(),
docs: docs(),
package: package(),
test_coverage: [tool: ExCoveralls]]
[
app: :romeo,
name: "Romeo",
version: @version,
elixir: "~> 1.1",
build_embedded: Mix.env() == :prod,
start_permanent: Mix.env() == :prod,
description: description(),
deps: deps(),
docs: docs(),
package: package(),
test_coverage: [tool: ExCoveralls]
]
end

def application do
[applications: [:logger, :connection, :fast_xml],
mod: {Romeo, []}]
[applications: [:logger, :connection, :fast_xml], mod: {Romeo, []}]
end

defp description do
"An XMPP Client for Elixir"
end

defp deps do
[{:connection, "~> 1.0"},
{:fast_xml, "~> 1.1"},
[
{:connection, "~> 1.0"},
{:fast_xml, "~> 1.1"},

# Docs deps
{:ex_doc, "~> 0.18", only: :dev},
# Docs deps
{:ex_doc, "~> 0.18", only: :dev},

# Test deps
{:ejabberd, github: "scrogson/ejabberd", branch: "fix_mix_compile", only: :test},
{:excoveralls, "~> 0.8", only: :test}]
# Test deps
# {:ejabberd, github: "scrogson/ejabberd", branch: "fix_mix_compile", only: :test, manager: :rebar3},
{:excoveralls, "~> 0.8", only: :test}
]
end

defp docs do
[extras: docs_extras(),
main: "readme"]
[extras: docs_extras(), main: "readme"]
end

defp docs_extras do
["README.md"]
end

defp package do
[files: ["lib", "mix.exs", "README.md", "LICENSE"],
maintainers: ["Sonny Scroggin"],
licenses: ["MIT"],
links: %{"GitHub" => "https://github.com/scrogson/romeo"}]
[
files: ["lib", "mix.exs", "README.md", "LICENSE"],
maintainers: ["Sonny Scroggin"],
licenses: ["MIT"],
links: %{"GitHub" => "https://github.com/scrogson/romeo"}
]
end
end
28 changes: 14 additions & 14 deletions mix.lock
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
%{
"cache_tab": {:hex, :cache_tab, "1.0.12", "a06a4ffbd4da8469791ba941512a6a45ed8c11865b4606a368e21b332da3638a", [], [{:p1_utils, "1.0.10", [hex: :p1_utils, repo: "hexpm", optional: false]}], "hexpm"},
"certifi": {:hex, :certifi, "2.0.0", "a0c0e475107135f76b8c1d5bc7efb33cd3815cb3cf3dea7aefdd174dabead064", [], [], "hexpm"},
"connection": {:hex, :connection, "1.0.4", "a1cae72211f0eef17705aaededacac3eb30e6625b04a6117c1b2db6ace7d5976", [], [], "hexpm"},
"certifi": {:hex, :certifi, "2.0.0", "a0c0e475107135f76b8c1d5bc7efb33cd3815cb3cf3dea7aefdd174dabead064", [:rebar3], [], "hexpm"},
"connection": {:hex, :connection, "1.0.4", "a1cae72211f0eef17705aaededacac3eb30e6625b04a6117c1b2db6ace7d5976", [:mix], [], "hexpm"},
"distillery": {:hex, :distillery, "1.5.2", "eec18b2d37b55b0bcb670cf2bcf64228ed38ce8b046bb30a9b636a6f5a4c0080", [], [], "hexpm"},
"earmark": {:hex, :earmark, "1.2.4", "99b637c62a4d65a20a9fb674b8cffb8baa771c04605a80c911c4418c69b75439", [], [], "hexpm"},
"earmark": {:hex, :earmark, "1.2.4", "99b637c62a4d65a20a9fb674b8cffb8baa771c04605a80c911c4418c69b75439", [:mix], [], "hexpm"},
"ejabberd": {:hex, :ejabberd, "18.1.0", "5bc81d975a0094c8ba9c809fdf6b8c03a90d4c62022c9c52a2adab235d5adb5d", [], [{:cache_tab, "~> 1.0", [hex: :cache_tab, repo: "hexpm", optional: false]}, {:distillery, "~> 1.0", [hex: :distillery, repo: "hexpm", optional: false]}, {:esip, "~> 1.0", [hex: :esip, repo: "hexpm", optional: false]}, {:ezlib, "~> 1.0", [hex: :ezlib, repo: "hexpm", optional: false]}, {:fast_tls, "~> 1.0", [hex: :fast_tls, repo: "hexpm", optional: false]}, {:fast_xml, "~> 1.1", [hex: :fast_xml, repo: "hexpm", optional: false]}, {:fast_yaml, "~> 1.0", [hex: :fast_yaml, repo: "hexpm", optional: false]}, {:fs, "~> 3.4", [hex: :fs, repo: "hexpm", optional: false]}, {:iconv, "~> 1.0", [hex: :iconv, repo: "hexpm", optional: false]}, {:jiffy, "~> 0.14.7", [hex: :jiffy, repo: "hexpm", optional: false]}, {:lager, "~> 3.4.0", [hex: :lager, repo: "hexpm", optional: false]}, {:p1_mysql, "~> 1.0", [hex: :p1_mysql, repo: "hexpm", optional: false]}, {:p1_oauth2, "~> 0.6.1", [hex: :p1_oauth2, repo: "hexpm", optional: false]}, {:p1_pgsql, "~> 1.1", [hex: :p1_pgsql, repo: "hexpm", optional: false]}, {:p1_utils, "~> 1.0", [hex: :p1_utils, repo: "hexpm", optional: false]}, {:stringprep, "~> 1.0", [hex: :stringprep, repo: "hexpm", optional: false]}, {:stun, "~> 1.0", [hex: :stun, repo: "hexpm", optional: false]}, {:xmpp, "~> 1.1", [hex: :xmpp, repo: "hexpm", optional: false]}], "hexpm"},
"esip": {:hex, :esip, "1.0.21", "711c704337d434db6d7c70bd0da868aaacd91b252c0bb63b4580e6c896164f1f", [], [{:fast_tls, "1.0.20", [hex: :fast_tls, repo: "hexpm", optional: false]}, {:p1_utils, "1.0.10", [hex: :p1_utils, repo: "hexpm", optional: false]}, {:stun, "1.0.20", [hex: :stun, repo: "hexpm", optional: false]}], "hexpm"},
"ex_doc": {:hex, :ex_doc, "0.18.1", "37c69d2ef62f24928c1f4fdc7c724ea04aecfdf500c4329185f8e3649c915baf", [], [{:earmark, "~> 1.1", [hex: :earmark, repo: "hexpm", optional: false]}], "hexpm"},
"excoveralls": {:hex, :excoveralls, "0.8.0", "99d2691d3edf8612f128be3f9869c4d44b91c67cec92186ce49470ae7a7404cf", [], [{:exjsx, ">= 3.0.0", [hex: :exjsx, repo: "hexpm", optional: false]}, {:hackney, ">= 0.12.0", [hex: :hackney, repo: "hexpm", optional: false]}], "hexpm"},
"exjsx": {:hex, :exjsx, "4.0.0", "60548841e0212df401e38e63c0078ec57b33e7ea49b032c796ccad8cde794b5c", [], [{:jsx, "~> 2.8.0", [hex: :jsx, repo: "hexpm", optional: false]}], "hexpm"},
"ex_doc": {:hex, :ex_doc, "0.18.1", "37c69d2ef62f24928c1f4fdc7c724ea04aecfdf500c4329185f8e3649c915baf", [:mix], [{:earmark, "~> 1.1", [hex: :earmark, repo: "hexpm", optional: false]}], "hexpm"},
"excoveralls": {:hex, :excoveralls, "0.8.0", "99d2691d3edf8612f128be3f9869c4d44b91c67cec92186ce49470ae7a7404cf", [:mix], [{:exjsx, ">= 3.0.0", [hex: :exjsx, repo: "hexpm", optional: false]}, {:hackney, ">= 0.12.0", [hex: :hackney, repo: "hexpm", optional: false]}], "hexpm"},
"exjsx": {:hex, :exjsx, "4.0.0", "60548841e0212df401e38e63c0078ec57b33e7ea49b032c796ccad8cde794b5c", [:mix], [{:jsx, "~> 2.8.0", [hex: :jsx, repo: "hexpm", optional: false]}], "hexpm"},
"ezlib": {:hex, :ezlib, "1.0.3", "c402c839ff5eab5b8a69efd9f60885c3ab3ca2489a6758bf8a67c914297597c5", [], [], "hexpm"},
"fast_tls": {:hex, :fast_tls, "1.0.20", "edd241961ab20b71ec1e9f75a2a2c043128ff117adf3efd42e6cec94f1937539", [], [{:p1_utils, "1.0.10", [hex: :p1_utils, repo: "hexpm", optional: false]}], "hexpm"},
"fast_xml": {:hex, :fast_xml, "1.1.28", "31ce5cf44d20e900e1a499009f886ff74b589324d532ed0ed7a432e4f498beb1", [:rebar3], [{:p1_utils, "1.0.10", [hex: :p1_utils, repo: "hexpm", optional: false]}], "hexpm"},
"fast_yaml": {:hex, :fast_yaml, "1.0.12", "ee8527d388255cf7a24fc1e6cb2d09dca4e506966dd9d86e61d3d90f236a3e2e", [], [{:p1_utils, "1.0.10", [hex: :p1_utils, repo: "hexpm", optional: false]}], "hexpm"},
"fs": {:hex, :fs, "3.4.0", "6d18575c250b415b3cad559e6f97a4c822516c7bc2c10bfbb2493a8f230f5132", [], [], "hexpm"},
"goldrush": {:hex, :goldrush, "0.1.9", "f06e5d5f1277da5c413e84d5a2924174182fb108dabb39d5ec548b27424cd106", [], [], "hexpm"},
"hackney": {:hex, :hackney, "1.11.0", "4951ee019df102492dabba66a09e305f61919a8a183a7860236c0fde586134b6", [], [{:certifi, "2.0.0", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "5.1.0", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "1.0.1", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "1.0.2", [hex: :mimerl, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "1.1.1", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}], "hexpm"},
"hackney": {:hex, :hackney, "1.11.0", "4951ee019df102492dabba66a09e305f61919a8a183a7860236c0fde586134b6", [:rebar3], [{:certifi, "2.0.0", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "5.1.0", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "1.0.1", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "1.0.2", [hex: :mimerl, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "1.1.1", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}], "hexpm"},
"iconv": {:hex, :iconv, "1.0.6", "3b424a80039059767f1037dc6a49ff07c2f88df14068c16dc938c4f377a77b4c", [], [{:p1_utils, "1.0.10", [hex: :p1_utils, repo: "hexpm", optional: false]}], "hexpm"},
"idna": {:hex, :idna, "5.1.0", "d72b4effeb324ad5da3cab1767cb16b17939004e789d8c0ad5b70f3cea20c89a", [], [{:unicode_util_compat, "0.3.1", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm"},
"idna": {:hex, :idna, "5.1.0", "d72b4effeb324ad5da3cab1767cb16b17939004e789d8c0ad5b70f3cea20c89a", [:rebar3], [{:unicode_util_compat, "0.3.1", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm"},
"jiffy": {:hex, :jiffy, "0.14.13", "225a9a35e26417832c611526567194b4d3adc4f0dfa5f2f7008f4684076f2a01", [], [], "hexpm"},
"jsx": {:hex, :jsx, "2.8.3", "a05252d381885240744d955fbe3cf810504eb2567164824e19303ea59eef62cf", [], [], "hexpm"},
"jsx": {:hex, :jsx, "2.8.3", "a05252d381885240744d955fbe3cf810504eb2567164824e19303ea59eef62cf", [:mix, :rebar3], [], "hexpm"},
"lager": {:hex, :lager, "3.4.2", "150b9a17b23ae6d3265cc10dc360747621cf217b7a22b8cddf03b2909dbf7aa5", [], [{:goldrush, "0.1.9", [hex: :goldrush, repo: "hexpm", optional: false]}], "hexpm"},
"metrics": {:hex, :metrics, "1.0.1", "25f094dea2cda98213cecc3aeff09e940299d950904393b2a29d191c346a8486", [], [], "hexpm"},
"mimerl": {:hex, :mimerl, "1.0.2", "993f9b0e084083405ed8252b99460c4f0563e41729ab42d9074fd5e52439be88", [], [], "hexpm"},
"metrics": {:hex, :metrics, "1.0.1", "25f094dea2cda98213cecc3aeff09e940299d950904393b2a29d191c346a8486", [:rebar3], [], "hexpm"},
"mimerl": {:hex, :mimerl, "1.0.2", "993f9b0e084083405ed8252b99460c4f0563e41729ab42d9074fd5e52439be88", [:rebar3], [], "hexpm"},
"p1_mysql": {:hex, :p1_mysql, "1.0.4", "7b9d7957a9d031813a0e6bcea5a7f5e91b54db805a92709a445cf75cf934bc1d", [], [], "hexpm"},
"p1_oauth2": {:hex, :p1_oauth2, "0.6.2", "cc381038920e3d34ef32aa10ba7eb637bdff38a946748c4fd99329ff484a3889", [], [], "hexpm"},
"p1_pgsql": {:hex, :p1_pgsql, "1.1.4", "eadbbddee8d52145694bf86bdfe8c1ae8353a55e152410146b8c2711756d6041", [], [], "hexpm"},
"p1_utils": {:hex, :p1_utils, "1.0.10", "a6d6927114bac79cf6468a10824125492034af7071adc6ed5ebc4ddb443845d4", [], [], "hexpm"},
"ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.1", "28a4d65b7f59893bc2c7de786dec1e1555bd742d336043fe644ae956c3497fbe", [], [], "hexpm"},
"p1_utils": {:hex, :p1_utils, "1.0.10", "a6d6927114bac79cf6468a10824125492034af7071adc6ed5ebc4ddb443845d4", [:rebar3], [], "hexpm"},
"ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.1", "28a4d65b7f59893bc2c7de786dec1e1555bd742d336043fe644ae956c3497fbe", [:make, :rebar], [], "hexpm"},
"stringprep": {:hex, :stringprep, "1.0.10", "552d784eb60652220fce9131f8bb0ebc62fdffd6482c4f08f2e7d61300227c28", [], [{:p1_utils, "1.0.10", [hex: :p1_utils, repo: "hexpm", optional: false]}], "hexpm"},
"stun": {:hex, :stun, "1.0.20", "6b156fa11606bebb6086d02cb2f6532c84effb59c95ba93d0e2d8e2510970253", [], [{:fast_tls, "1.0.20", [hex: :fast_tls, repo: "hexpm", optional: false]}, {:p1_utils, "1.0.10", [hex: :p1_utils, repo: "hexpm", optional: false]}], "hexpm"},
"unicode_util_compat": {:hex, :unicode_util_compat, "0.3.1", "a1f612a7b512638634a603c8f401892afbf99b8ce93a45041f8aaca99cadb85e", [], [], "hexpm"},
"unicode_util_compat": {:hex, :unicode_util_compat, "0.3.1", "a1f612a7b512638634a603c8f401892afbf99b8ce93a45041f8aaca99cadb85e", [:rebar3], [], "hexpm"},
"xmpp": {:hex, :xmpp, "1.1.19", "ca0a89c567e972d119204b1296ffe58ad5d3237738950ae2c61043fbaf5e150e", [:rebar3], [{:fast_xml, "1.1.28", [hex: :fast_xml, repo: "hexpm", optional: false]}, {:p1_utils, "1.0.10", [hex: :p1_utils, repo: "hexpm", optional: false]}, {:stringprep, "1.0.10", [hex: :stringprep, repo: "hexpm", optional: false]}], "hexpm"},
}