-
Notifications
You must be signed in to change notification settings - Fork 305
API Reference
Wiki ▸ API Reference
Everything in PhoneRTC is scoped under the phonertc
namespace.
A session represents a connection between 2 users.
# Session(config)
Construct a new Session based on the config
parameter. The config
parameter should be an object with the following properties:
-
isInitiator
(boolean) - determines whether or not this session sends the WebRTC offer. -
turn
(object) - represents the details of the TURN server. Has 3 string properties:host
,username
andpassword
. -
streams
(object) - represents which tracks will be sent. Has 2 boolean properties:audio
,video
.
# Session.on(eventName, fn)
Attach an event handler function for one or more events to the session. The available events are:
-
sendMessage
- when PhoneRTC wants to send a message to the peer -
answer
- when the connection has successfully established -
disconnect
- when one side ends the session
# Session.off(eventName, fn)
Remove an event handler.
# Session.receiveMessage(data)
Handle a message that was sent by the session peer. data
must be an object.
# Session.call()
Initialize a call by starting the PhoneRTC handshaking process.
Note that this should be called on the client with config.isInitiator = false
before the client with config.isInitiator = true
.