Created
September 23, 2016 15:25
-
-
Save sorentwo/32562a7e0b742fe5a24896e00a31ae15 to your computer and use it in GitHub Desktop.
Listen and loop with elixir socket
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
| def loop(socket) do | |
| case socket |> Socket.Web.recv! do | |
| {:text, data} -> | |
| # process data | |
| loop(socket) | |
| {:ping, _ } -> | |
| socket |> Socket.Web.send!({:pong, ""}) | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment