View Source Fishjam.WSNotifier (Fishjam Server SDK v0.6.0)
Module defining a process responsible for establishing WebSocket connection and receiving events from Fishjam server.
First, configure the connection options.
# Start the Notifier
iex> {:ok, notifier} = Fishjam.WSNotifier.start()
{:ok, #PID<0.301.0>}
# Subscribe current process to server notifications.
iex> :ok = Fishjam.WSNotifier.subscribe_server_notifications(notifier)
# here add a room and a peer using functions from `Fishjam.Room` module
# you should receive a notification after the peer established connection
iex> flush()
{:fishjam, %Fishjam.Notification.PeerConnected{
room_id: "21604fbe-8ac8-44e6-8474-98b5f50f1863",
peer_id: "ae07f94e-0887-44c3-81d5-bfa9eac96252"
}}
:ok
When starting the Notifier, you can provide the name under which the process will be registered.
iex> {:ok, notifier} = Fishjam.WSNotifier.start_link(name: Fishjam.WSNotifier)
Summary
Functions
Starts the Notifier process and connects to Fishjam.
Starts the Notifier process and connects to Fishjam.
Subscribes the process to the WebRTC metrics from all the rooms.
Subscribes the process to receive server notifications from all the rooms.
Types
@type notifier() :: GenServer.server()
The reference to the Notifier
process.
@type options() :: [ server_address: String.t(), server_api_token: String.t(), secure?: boolean(), name: GenServer.name() ]
Connection options used to connect to Fishjam server.
Functions
Starts the Notifier process and connects to Fishjam.
To learn how to receive notifications, see subscribe/3
.
For information about options, see Fishjam.Client.connection_options/0
.
Starts the Notifier process and connects to Fishjam.
Acts like start/1
but links to the calling process.
See start/1
for more information.
@spec subscribe_metrics(notifier()) :: :ok | {:error, :timeout}
Subscribes the process to the WebRTC metrics from all the rooms.
Metrics are periodically sent to the process in a form of {:fishjam, metrics_report}
,
where metrics_report
is the Fishjam.MetricsReport
struct.
Subscribes the process to receive server notifications from all the rooms.
Notifications are sent to the process in a form of {:fishjam, msg}
,
where msg
is one of structs defined under "Fishjam.Notification" section in the docs,
for example {:fishjam, %Fishjam.Notification.RoomCrashed{room_id: "some_id"}}
.