Created
March 1, 2016 17:19
-
-
Save kyle-eshares/963521dc6e56438e5adc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule SimpleTCP.Sender do | |
use GenServer | |
import Socket | |
def start_link(socket, opts \\ []) do | |
GenServer.start_link(__MODULE__, [socket: socket], opts) | |
end | |
def init(socket) do | |
# Register the process with gproc and subcscribe to :something | |
:gproc.reg({:p, :l, :something}) | |
{:ok, socket} | |
end | |
def handle_cast({:msg, msg}, [socket: socket] = state) do | |
Socket.Stream.send(socket, msg) | |
{:noreply, state} | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment