Table of Contents
onWrtcCmd()
wrtc.onWrtcCmd() is an event function called when user command has been received through RTCgate signaling channel.
You can use this event to take care of the incoming user command.
Arguments
wrtc.onWrtcCmd(obj, msg)
- obj - object: either a call object (indicating sender used call.adv.sendWrtcCmd() to send) or the wrtc object (indicating sender used wrtc.adv.sendWrtcCmd() to send)
- msg - the wrtc message received through the data channel:
- msg.from - addressName of sender
- msg.cmd - the user command (string or JSON)
Return value
Ignored.
Example
If sending client has sent {cmd: "ping"} using
call.adv.sendWrtcCmd({cmd: "ping"});
you will receive a wrtc.onWrtcCmd() call with {cmd: "ping"} in its msg.cmd argument. Then you can respond with {cmd: "pong"}:
wrtc.onWrtcCmd= function(obj, msg) {
if ((msg.cmd.cmd) && (msg.cmd.cmd == "ping"))
if (obj.objType == "call")
obj.adv.sendWrtcCmd({cmd: "pong"});
else
wrtc.adv.sendWrtcCmd(msg.from, {cmd: "pong"});
}