Pushest v0.2.2 Pushest.Socket.Utils View Source
Various Socket-scoped utilities.
Link to this section Summary
Functions
Returns auth token needed to authorize our client against Pusher server when subscribing to private or presence channel. Token is generated only for those two channel types as it’s not needed for public channels subscriptions
Generates Url struct with domain, path and port parts needed to build Pusher Server URL for given Pusher app key and configuration. String values are converted to charlist since that is the accepted format for underlying :gun lib
Checks whether user_data
map contains mandatory element user_id
and its
content is valid. Used when subscribing to presence channel as user_id is
necessary there
Link to this section Functions
Returns auth token needed to authorize our client against Pusher server when subscribing to private or presence channel. Token is generated only for those two channel types as it’s not needed for public channels subscriptions.
Generates Url struct with domain, path and port parts needed to build Pusher Server URL for given Pusher app key and configuration. String values are converted to charlist since that is the accepted format for underlying :gun lib.
Checks whether user_data
map contains mandatory element user_id
and its
content is valid. Used when subscribing to presence channel as user_id is
necessary there.
Examples
iex> Pushest.Socket.Utils.validate_user_data(%{user_id: 1})
{:ok, %{user_id: 1}}
iex> Pushest.Socket.Utils.validate_user_data(%{user_id: "1"})
{:ok, %{user_id: "1"}}
iex> Pushest.Socket.Utils.validate_user_data(%{user_id: ""})
{:error, %{user_id: ""}}
iex> Pushest.Socket.Utils.validate_user_data(%{user_id: nil})
{:error, %{user_id: nil}}
iex> Pushest.Socket.Utils.validate_user_data(%{})
{:error, %{}}