Class: Easyrtc_App

Easyrtc_App

new Easyrtc_App()

This file adds additional methods to Easyrtc for simplifying the management of video-mediastream assignment.

Methods

<static> easyrtc.dontAddCloseButtons()

By default, the easyApp routine sticks a "close" button on top of each caller video object that it manages. Call this function(before calling easyApp) to disable that particular feature.
Example
easyrtc.dontAddCloseButtons();

<static> easyrtc.easyApp(applicationName, monitorVideoId, videoIds, onReady, onFailure)

Provides a layer on top of the easyrtc.initMediaSource and easyrtc.connect, assign the local media stream to the video object identified by monitorVideoId, assign remote video streams to the video objects identified by videoIds, and then call onReady. One of it's side effects is to add hangup buttons to the remote video objects, buttons that only appear when you hover over them with the mouse cursor. This method will also add the easyrtcMirror class to the monitor video object so that it behaves like a mirror.
Parameters:
Name Type Description
applicationName String name of the application.
monitorVideoId String the id of the video object used for monitoring the local stream.
videoIds Array an array of video object ids (strings)
onReady function a callback function used on success. It is called with the easyrtcId this peer is known to the server as.
onFailure function a callback function used on failure (failed to get local media or a connection of the signaling server).
Example
easyrtc.easyApp('multiChat', 'selfVideo', ['remote1', 'remote2', 'remote3'],
             function(easyrtcId){
                 console.log("successfully connected, I am " + easyrtcId);
             },
             function(errorCode, errorText){
                 console.log(errorText);
             });

<static> easyrtc.getIthCaller(i) → {String}

Get the easyrtcid of the ith caller, starting at 0.
Parameters:
Name Type Description
i number
Returns:
Type
String

<static> easyrtc.getSlotOfCaller(easyrtcid) → {number}

This is the complement of getIthCaller. Given an easyrtcid, it determines which slot the easyrtc is in.
Parameters:
Name Type Description
easyrtcid string
Returns:
or -1 if the easyrtcid is not a caller.
Type
number

<static> easyrtc.setGotConnection(gotConnectionCB)

Sets an event handler that gets called when a connection to the signaling server has or has not been made. Can only be called after calling easyrtc.easyApp.
Parameters:
Name Type Description
gotConnectionCB function has the signature (gotConnection, errorText)
Example
easyrtc.setGotConnection( function(gotConnection, errorText){
       if( gotConnection ){
           console.log("Successfully connected to signaling server");
       }
       else{
           console.log("Failed to connect to signaling server because: " + errorText);
       }
   });

<static> easyrtc.setOnCall(cb)

Sets an event handler that gets called when an incoming MediaStream is assigned to a video object. The name is poorly chosen and reflects a simpler era when you could only have one media stream per peer connection.
Parameters:
Name Type Description
cb function has the signature function(easyrtcid, slot){}
Example
easyrtc.setOnCall( function(easyrtcid, slot){
     console.log("call with " + easyrtcid + "established");
  });

<static> easyrtc.setOnHangup(cb)

Sets an event handler that gets called when a call is ended. it's only purpose (so far) is to support transitions on video elements. x * this function is only defined after easyrtc.easyApp is called. The slot is parameter is the index into the array of video ids. Note: if you call easyrtc.getConnectionCount() from inside your callback it's count will reflect the number of connections before the hangup started.
Parameters:
Name Type Description
cb function has the signature function(easyrtcid, slot){}
Example
easyrtc.setOnHangup( function(easyrtcid, slot){
     console.log("call with " + easyrtcid + "ended");
  });
Documentation generated by JSDoc 3.6.11 on 2023-05-30T12:08:53+00:00