Skip to content

Commit

Permalink
janus.js: connectionState callback added (#3342)
Browse files Browse the repository at this point in the history
  • Loading branch information
RSATom committed Mar 29, 2024
1 parent 43cd5bd commit a7a9938
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
7 changes: 7 additions & 0 deletions html/janus.js
Original file line number Diff line number Diff line change
Expand Up @@ -1161,6 +1161,7 @@ function Janus(gatewayCallbacks) {
callbacks.error = (typeof callbacks.error == "function") ? callbacks.error : Janus.noop;
callbacks.dataChannelOptions = callbacks.dataChannelOptions || { ordered: true };
callbacks.consentDialog = (typeof callbacks.consentDialog == "function") ? callbacks.consentDialog : Janus.noop;
callbacks.connectionState = (typeof callbacks.connectionState == "function") ? callbacks.connectionState : Janus.noop;
callbacks.iceState = (typeof callbacks.iceState == "function") ? callbacks.iceState : Janus.noop;
callbacks.mediaState = (typeof callbacks.mediaState == "function") ? callbacks.mediaState : Janus.noop;
callbacks.webrtcState = (typeof callbacks.webrtcState == "function") ? callbacks.webrtcState : Janus.noop;
Expand Down Expand Up @@ -1251,6 +1252,7 @@ function Janus(gatewayCallbacks) {
data : function(callbacks) { sendData(handleId, callbacks); },
dtmf : function(callbacks) { sendDtmf(handleId, callbacks); },
consentDialog : callbacks.consentDialog,
connectionState : callbacks.connectionState,
iceState : callbacks.iceState,
mediaState : callbacks.mediaState,
webrtcState : callbacks.webrtcState,
Expand Down Expand Up @@ -1337,6 +1339,7 @@ function Janus(gatewayCallbacks) {
data : function(callbacks) { sendData(handleId, callbacks); },
dtmf : function(callbacks) { sendDtmf(handleId, callbacks); },
consentDialog : callbacks.consentDialog,
connectionState : callbacks.connectionState,
iceState : callbacks.iceState,
mediaState : callbacks.mediaState,
webrtcState : callbacks.webrtcState,
Expand Down Expand Up @@ -1850,6 +1853,10 @@ function Janus(gatewayCallbacks) {
config.bitrate.value = "0 kbits/sec";
}
Janus.log("Preparing local SDP and gathering candidates (trickle=" + config.trickle + ")");
config.pc.onconnectionstatechange = function() {
if(config.pc)
pluginHandle.connectionState(config.pc.connectionState);
};
config.pc.oniceconnectionstatechange = function() {
if(config.pc)
pluginHandle.iceState(config.pc.iceConnectionState);
Expand Down
3 changes: 3 additions & 0 deletions mainpage.dox
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,9 @@ var janus = new Janus(
* when WebRTC is actually up and running between you and Janus (e.g., to notify
* a user they're actually now active in a conference); notice that in case
* of <b>false</b> a reason string may be present as an optional parameter;
* - \c connectionState: this callback is triggered when the connection state for the
* PeerConnection associated to the handle changes: the argument of the callback
* is the new state as a string (e.g., "connected" or "failed");
* - \c iceState: this callback is triggered when the ICE state for the
* PeerConnection associated to the handle changes: the argument of the callback
* is the new state as a string (e.g., "connected" or "failed");
Expand Down

0 comments on commit a7a9938

Please sign in to comment.