From da1ce1e35093499143eff49b55db3fdfbbd88c86 Mon Sep 17 00:00:00 2001 From: Paul Schoenfelder Date: Thu, 1 Dec 2016 16:09:20 -0600 Subject: Close #58 - address linking of client processes in examples --- README.md | 4 ++-- examples/bot/lib/bot.ex | 2 +- lib/exirc/exirc.ex | 9 ++++++++- mix.lock | 2 +- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index f517cdf..04eea27 100644 --- a/README.md +++ b/README.md @@ -51,7 +51,7 @@ defmodule ExampleSupervisor do def init(state) do # Start the client and handler processes, the ExIrc supervisor is automatically started when your app runs - {:ok, client} = ExIrc.start_client!() + {:ok, client} = ExIrc.start_link!() {:ok, handler} = ExampleHandler.start_link(nil) # Register the event handler with ExIrc @@ -88,7 +88,7 @@ defmodule ExampleApplication do def start(_type, _args) do import Supervisor.Spec, warn: false - {:ok, client} = ExIrc.start_client! + {:ok, client} = ExIrc.start_link! children = [ # Define workers and child supervisors to be supervised diff --git a/examples/bot/lib/bot.ex b/examples/bot/lib/bot.ex index 46dd6b6..85d3ffc 100644 --- a/examples/bot/lib/bot.ex +++ b/examples/bot/lib/bot.ex @@ -31,7 +31,7 @@ defmodule Example.Bot do def init([config]) do # Start the client and handler processes, the ExIrc supervisor is automatically started when your app runs - {:ok, client} = ExIrc.start_client!() + {:ok, client} = ExIrc.start_link!() # Register the event handler with ExIrc Client.add_handler client, self() diff --git a/lib/exirc/exirc.ex b/lib/exirc/exirc.ex index b32af54..c36e6e4 100644 --- a/lib/exirc/exirc.ex +++ b/lib/exirc/exirc.ex @@ -45,7 +45,7 @@ defmodule ExIrc do end @doc """ - Start a new ExIrc client + Start a new ExIrc client under the ExIrc supervisor """ @spec start_client! :: {:ok, pid} | {:error, term} def start_client! do @@ -53,6 +53,13 @@ defmodule ExIrc do Supervisor.start_child(:exirc, [[owner: self()]]) end + @doc """ + Start a new ExIrc client + """ + def start_link! do + ExIrc.Client.start!([owner: self()]) + end + ############## # Supervisor API ############## diff --git a/mix.lock b/mix.lock index 83b9d0f..01b6bab 100644 --- a/mix.lock +++ b/mix.lock @@ -8,4 +8,4 @@ "jsx": {:hex, :jsx, "2.8.0", "749bec6d205c694ae1786d62cea6cc45a390437e24835fd16d12d74f07097727", [:mix, :rebar], []}, "metrics": {:hex, :metrics, "1.0.1", "25f094dea2cda98213cecc3aeff09e940299d950904393b2a29d191c346a8486", [:rebar3], []}, "mimerl": {:hex, :mimerl, "1.0.2", "993f9b0e084083405ed8252b99460c4f0563e41729ab42d9074fd5e52439be88", [:rebar3], []}, - "ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.0", "edee20847c42e379bf91261db474ffbe373f8acb56e9079acb6038d4e0bf414f", [:rebar, :make], []}} + "ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.0", "edee20847c42e379bf91261db474ffbe373f8acb56e9079acb6038d4e0bf414f", [:make, :rebar], []}} -- cgit v1.2.3