Last active
July 17, 2018 16:00
-
-
Save cybrox/c0f4f55dad55a86bb0e511498b8ead55 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 RaymanPlayground.Application do | |
@moduledoc false | |
use Application | |
def start(_type, _args) do | |
{:ok, pid} = :gen_tcp.listen(1883, [ | |
:binary, | |
active: false, | |
reuseaddr: true | |
]) | |
server = spawn(fn -> | |
await_connection(pid) | |
end) | |
{:ok, server} | |
end | |
defp await_connection(pid) do | |
{:ok, client} = :gen_tcp.accept(pid) | |
read_data(client) | |
await_connection(pid) | |
end | |
defp read_data(client) do | |
{:ok, data} = :gen_tcp.recv(client, 0) | |
Rayman.decode_packet(data) | |
read_data(client) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment