Polymarket.WebSocket.MessageHandler (Polymarket v0.1.1)

Copy Markdown View Source

Pure functions to handle messages coming from the Polymarket websocket.

Summary

Functions

Handles an event from the websocket.

Functions

handle_message(message, state)

@spec handle_message(map(), Polymarket.WebSocket.t()) ::
  {:reply, {:text, String.t()}, Polymarket.WebSocket.t()}
  | {:noreply, Polymarket.WebSocket.t()}

Handles an event from the websocket.

Decodes the event into a struct if possible, then forwards it to the handler module injected into the websocket state (state.handler). Prints a warning if the event is undecodable.