PS2.ESS.Conn (PlanetSide 2 API v1.0.0)

View Source

Summary

Functions

Returns the current subscription of the given ESS connection

Handles websocket messages. The process that called new/1,2 will receive messages that should be passed to this function for processing.

Resends the subscription message down the websocket, assuming at least one subscription was sent previously. Useful in cases where ESS may mysteriously stop sending events of a certain kind. Alternatively, consider killing the connection altogether for a fresh start.

Sends a new subscription message down the socket. Since subscriptions are additive, the given %PS2.ESS.Subscription{} will add to subscriptions of any previous calls to this function. If the given subscription sets clear?: true, it will remove the specified items from your total subscription set.

Types

event()

@type event() :: map()

send_subscription_result()

@type send_subscription_result() ::
  {:ok, t()}
  | {:error, t(), :conn_not_upgraded | Mint.WebSocket.error() | any()}

t()

@opaque t()

Functions

close(ess_conn)

current_subscription(conn)

@spec current_subscription(t()) :: PS2.ESS.Subscription.t() | nil

Returns the current subscription of the given ESS connection

default_mint_opts()

handle_message(ess_conn, message)

@spec handle_message(t(), message :: term()) ::
  {:connected, t()}
  | {:ok, t(), [event()]}
  | {:error, t(), Mint.WebSocket.error() | :unexpected_upgrade_response}

Handles websocket messages. The process that called new/1,2 will receive messages that should be passed to this function for processing.

new(uri, sid_fxn, sub \\ nil, mint_opts \\ [transport_opts: [versions: [:"tlsv1.2"]]])

send_subscription(ess_conn)

@spec send_subscription(t()) ::
  send_subscription_result() | {:error, t(), :no_subscription_given}

Resends the subscription message down the websocket, assuming at least one subscription was sent previously. Useful in cases where ESS may mysteriously stop sending events of a certain kind. Alternatively, consider killing the connection altogether for a fresh start.

Since subscriptions are additive, if more than one subscription message was sent earlier, the cumulative set of subscription will be resent.

send_subscription(ess_conn, sub)

@spec send_subscription(t(), PS2.ESS.Subscription.t()) ::
  {:ok, t()}
  | {:error, t(), :conn_not_upgraded | Mint.WebSocket.error() | any()}

Sends a new subscription message down the socket. Since subscriptions are additive, the given %PS2.ESS.Subscription{} will add to subscriptions of any previous calls to this function. If the given subscription sets clear?: true, it will remove the specified items from your total subscription set.