···11+# The directory Mix will write compiled artifacts to.
22+/_build/
33+44+# If you run "mix test --cover", coverage assets end up here.
55+/cover/
66+77+# The directory Mix downloads your dependencies sources to.
88+/deps/
99+1010+# Where third-party dependencies like ExDoc output generated docs.
1111+/doc/
1212+1313+# If the VM crashes, it generates a dump, let's ignore it too.
1414+erl_crash.dump
1515+1616+# Also ignore archive artifacts (built via "mix archive.build").
1717+*.ez
1818+1919+# Ignore package tarball (built via "mix hex.build").
2020+sower_client-*.tar
2121+2222+# Temporary files, for example, from tests.
2323+/tmp/
+21
client-elixir/README.md
···11+# SowerClient
22+33+**TODO: Add description**
44+55+## Installation
66+77+If [available in Hex](https://hex.pm/docs/publish), the package can be installed
88+by adding `sower_client` to your list of dependencies in `mix.exs`:
99+1010+```elixir
1111+def deps do
1212+ [
1313+ {:sower_client, "~> 0.1.0"}
1414+ ]
1515+end
1616+```
1717+1818+Documentation can be generated with [ExDoc](https://github.com/elixir-lang/ex_doc)
1919+and published on [HexDocs](https://hexdocs.pm). Once published, the docs can
2020+be found at <https://hexdocs.pm/sower_client>.
2121+
···11+defmodule SowerClient do
22+ @moduledoc """
33+ Documentation for `SowerClient`.
44+ """
55+66+ @doc """
77+ Hello world.
88+99+ ## Examples
1010+1111+ iex> SowerClient.hello()
1212+ :world
1313+1414+ """
1515+ def hello do
1616+ :world
1717+ end
1818+end
+20
client-elixir/lib/sower_client/application.ex
···11+defmodule SowerClient.Application do
22+ # See https://hexdocs.pm/elixir/Application.html
33+ # for more information on OTP Applications
44+ @moduledoc false
55+66+ use Application
77+88+ @impl true
99+ def start(_type, _args) do
1010+ children = [
1111+ # Starts a worker by calling: SowerClient.Worker.start_link(arg)
1212+ {SowerClient.SocketClient, []}
1313+ ]
1414+1515+ # See https://hexdocs.pm/elixir/Supervisor.html
1616+ # for other strategies and supported options
1717+ opts = [strategy: :one_for_one, name: SowerClient.Supervisor]
1818+ Supervisor.start_link(children, opts)
1919+ end
2020+end
+36
client-elixir/lib/sower_client/worker.ex
···11+defmodule SowerClient.SocketClient do
22+ use Slipstream
33+44+ require Logger
55+66+ @topic "client:lobby"
77+88+ def start_link(args) do
99+ Slipstream.start_link(__MODULE__, args, name: __MODULE__)
1010+ end
1111+1212+ @impl Slipstream
1313+ def init(_args) do
1414+ config = Application.fetch_env!(:sower_client, __MODULE__)
1515+1616+ case connect(config) do
1717+ {:ok, socket} ->
1818+ Logger.debug(msg: "Connecting")
1919+ {:ok, socket}
2020+2121+ {:error, reason} ->
2222+ Logger.error(
2323+ "Could not start #{__MODULE__} because of " <>
2424+ "validation failure: #{inspect(reason)}"
2525+ )
2626+2727+ :ignore
2828+ end
2929+ end
3030+3131+ @impl Slipstream
3232+ def handle_connect(socket) do
3333+ Logger.debug(msg: "Connected")
3434+ {:ok, join(socket, @topic)}
3535+ end
3636+end
+29
client-elixir/mix.exs
···11+defmodule SowerClient.MixProject do
22+ use Mix.Project
33+44+ def project do
55+ [
66+ app: :sower_client,
77+ version: "0.1.0",
88+ elixir: "~> 1.18",
99+ start_permanent: Mix.env() == :prod,
1010+ deps: deps()
1111+ ]
1212+ end
1313+1414+ # Run "mix help compile.app" to learn about applications.
1515+ def application do
1616+ [
1717+ extra_applications: [:logger],
1818+ mod: {SowerClient.Application, []}
1919+ ]
2020+ end
2121+2222+ # Run "mix help deps" to learn about dependencies.
2323+ defp deps do
2424+ [
2525+ {:slipstream, "~> 1.0"},
2626+ {:igniter, "~> 0.6", only: [:dev, :test]}
2727+ ]
2828+ end
2929+end
···11+defmodule SowerClientTest do
22+ use ExUnit.Case
33+ doctest SowerClient
44+55+ test "greets the world" do
66+ assert SowerClient.hello() == :world
77+ end
88+end