janus_ws v0.1.2 Janus.WS View Source
For interacting with Janus WebRTC Gateway via WebSockets.
Example project
https://github.com/janus-ex/janus_ws_example
Debugging
Same as in :websockex:
iex(1)> {:ok, client} = Janus.start_link(url: "ws://localhost:8188", registry: some_registry, debug: [:trace])
*DBG* #PID<0.209.0> attempting to connect
*DBG* #PID<0.209.0> sucessfully connected
*DBG* #PID<0.209.0> received cast msg: {:create_session, "Mbcb4i8dMfg", #PID<0.208.0>}
*DBG* #PID<0.209.0> replying from :handle_cast with {:text, "{\"janus\":\"create\",\"transaction\":\"Mbcb4i8dMfg\"}"}
*DBG* #PID<0.209.0> received frame: {:text, "{\"janus\":\"success\",\"transaction\":\"Mbcb4i8dMfg\",\"data\":{\"id\":818647816905897}}"}
*DBG* #PID<0.209.0> sending frame: {:text, "{\"janus\":\"destroy\",\"session_id\":818647816905897,\"transaction\":\"adZA+FChr1M\"}"}
*DBG* #PID<0.209.0> received frame: {:text, "{\"janus\":\"success\",\"session_id\":818647816905897,\"transaction\":\"adZA+FChr1M\"}"}
iex(2)> :sys.trace(client, false)
# ... silence ...
iex(3)> :sys.trace(client, true)
*DBG* #PID<0.209.0> received frame: {:text, "{\"janus\":\"ack\",\"session_id\":7564472917324192,\"transaction\":\"0Al6pqcEPgY\"}"}
*DBG* #PID<0.209.0> sending frame: {:text, "{\"candidate\":{\"completed\":true},\"handle_id\":8087962335175224,\"janus\":\"trickle\",\"session_id\":7564472917324192,\"transaction\":\"2g2m/wtyBRU\"}"}
*DBG* #PID<0.209.0> received frame: {:text, "{\"janus\":\"ack\",\"session_id\":7564472917324192,\"transaction\":\"2g2m/wtyBRU\"}"}
Link to this section Summary
Functions
To attach a plugin to a janus session
To create a janus session
To destroy a janus session
To detach a plugin from a janus session
To fetch info about the janus instance
To send a keepalive for a session
To send a message to a handle in a session
To send a trickle candidate for a session
Example
Link to this section Types
Link to this type
client()
View Source
client()
View Source
client() :: WebSockex.client()
client() :: WebSockex.client()
Link to this type
handle_id()
View Source
handle_id()
View Source
handle_id() :: integer()
handle_id() :: integer()
Link to this type
send_result()
View Source
send_result()
View Source
send_result() ::
{:ok, tx_id()}
| {:error,
%WebSockex.FrameEncodeError{
__exception__: term(),
close_code: term(),
frame_payload: term(),
frame_type: term(),
reason: term()
}
| %WebSockex.ConnError{__exception__: term(), original: term()}
| %WebSockex.NotConnectedError{
__exception__: term(),
connection_state: term()
}
| %WebSockex.InvalidFrameError{__exception__: term(), frame: term()}}
send_result() ::
{:ok, tx_id()}
| {:error,
%WebSockex.FrameEncodeError{
__exception__: term(),
close_code: term(),
frame_payload: term(),
frame_type: term(),
reason: term()
}
| %WebSockex.ConnError{__exception__: term(), original: term()}
| %WebSockex.NotConnectedError{
__exception__: term(),
connection_state: term()
}
| %WebSockex.InvalidFrameError{__exception__: term(), frame: term()}}
Link to this type
session_id()
View Source
session_id()
View Source
session_id() :: integer()
session_id() :: integer()
Link to this type
tx_id()
View Source
tx_id()
View Source
tx_id() :: String.t()
tx_id() :: String.t()
Link to this section Functions
Link to this function
attach(client, session_id, plugin)
View Source
attach(client, session_id, plugin)
View Source
attach(client(), session_id(), String.t()) :: send_result()
attach(client(), session_id(), String.t()) :: send_result()
To attach a plugin to a janus session
Link to this function
create_session(client, pid \\ self())
View Source
create_session(client, pid \\ self())
View Source
create_session(client(), pid()) :: send_result()
create_session(client(), pid()) :: send_result()
To create a janus session
Link to this function
destroy_session(client, session_id)
View Source
destroy_session(client, session_id)
View Source
destroy_session(client(), session_id()) :: send_result()
destroy_session(client(), session_id()) :: send_result()
To destroy a janus session
Link to this function
detach(client, session_id, handle_id)
View Source
detach(client, session_id, handle_id)
View Source
detach(client(), session_id(), handle_id()) :: send_result()
detach(client(), session_id(), handle_id()) :: send_result()
To detach a plugin from a janus session
Link to this function
info(client, pid \\ self())
View Source
info(client, pid \\ self())
View Source
info(client(), pid()) :: send_result()
info(client(), pid()) :: send_result()
To fetch info about the janus instance
Link to this function
send_keepalive(client, session_id)
View Source
send_keepalive(client, session_id)
View Source
send_keepalive(client(), session_id()) :: send_result()
send_keepalive(client(), session_id()) :: send_result()
To send a keepalive for a session
Link to this function
send_message(client, session_id, handle_id, data)
View Source
send_message(client, session_id, handle_id, data)
View Source
send_message(client(), session_id(), handle_id(), map()) :: send_result()
send_message(client(), session_id(), handle_id(), map()) :: send_result()
To send a message to a handle in a session
Link to this function
send_trickle_candidate(client, session_id, handle_id, candidates)
View Source
send_trickle_candidate(client, session_id, handle_id, candidates)
View Source
send_trickle_candidate(client(), session_id(), handle_id(), [map()]) ::
send_result()
send_trickle_candidate(client(), session_id(), handle_id(), map()) ::
send_result()
send_trickle_candidate(client(), session_id(), handle_id(), [map()]) :: send_result()
send_trickle_candidate(client(), session_id(), handle_id(), map()) :: send_result()
To send a trickle candidate for a session
Link to this function
start_link(opts) View Source
Example:
Registry.start_link(keys: :duplicate, name: Janus.WS.Session.Registry)
Janus.WS.start_link(url: "ws://localhost:8188", registry: Janus.WS.Session.Registry)