Bingex.Swap.EventSocket behaviour (Bingex v0.1.7)

defmodule EventSource do
  use Bingex.Swap.EventSocket
  require Logger

  alias Bingex.Swap.EventSocket
  alias Bingex.User

  def start_link(listen_key) do
    EventSocket.start_link(listen_key, __MODULE__, :state)
  end

  @impl true
  def handle_event(type, event, state) do
    Logger.info(%{ type: type, event: event, state: state })
    {:ok, state}
  end
end

Summary

Callbacks

handle_event(type, event, state)

@callback handle_event(
  type :: :config | :account | :trade,
  event ::
    Bingex.Swap.ConfigEvent.t()
    | Bingex.Swap.AccountEvent.t()
    | Bingex.Swap.TradeEvent.t(),
  state :: term()
) :: {:ok, state :: term()} | {:close, state :: term()}

Functions

call(pid, message, delay)

cast(pid, message)

start(listen_key, module, state, options \\ [])

start_link(listen_key, module, state, options \\ [])