translating websockets code to elixir