View Source Jellyfish.WSNotifier (Jellyfish Server SDK v0.5.1)
Module defining a process responsible for establishing WebSocket connection and receiving events from Jellyfish server.
First, configure the connection options.
# Start the Notifier
iex> {:ok, notifier} = Jellyfish.WSNotifier.start()
{:ok, #PID<0.301.0>}# Subscribe current process to server notifications.
iex> :ok = Jellyfish.WSNotifier.subscribe_server_notifications(notifier)
# here add a room and a peer using functions from `Jellyfish.Room` module
# you should receive a notification after the peer established connection
iex> flush()
{:jellyfish, %Jellyfish.Notification.PeerConnected{
room_id: "21604fbe-8ac8-44e6-8474-98b5f50f1863",
peer_id: "ae07f94e-0887-44c3-81d5-bfa9eac96252"
}}
:okWhen starting the Notifier, you can provide the name under which the process will be registered.
iex> {:ok, notifier} = Jellyfish.WSNotifier.start_link(name: Jellyfish.WSNotifier)
Summary
Types
The reference to the Notifier process.
Connection options used to connect to Jellyfish server.
Functions
Starts the Notifier process and connects to Jellyfish.
Starts the Notifier process and connects to Jellyfish.
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 Jellyfish server.
Functions
Starts the Notifier process and connects to Jellyfish.
To learn how to receive notifications, see subscribe/3.
For information about options, see Jellyfish.Client.connection_options/0.
Starts the Notifier process and connects to Jellyfish.
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 {:jellyfish, metrics_report},
where metrics_report is the Jellyfish.MetricsReport struct.
Subscribes the process to receive server notifications from all the rooms.
Notifications are sent to the process in a form of {:jellyfish, msg},
where msg is one of structs defined under "Jellyfish.Notification" section in the docs,
for example {:jellyfish, %Jellyfish.Notification.RoomCrashed{room_id: "some_id"}}.