Please Wait

Loading..

WebRTC SDK 1.0.0

Create amazing realtime applications easily with Yalgaar WebRTC SDK

.Net SDK

1 Connect To Yalgaar

Download package and insert library in head tag in your code.

<html>
    <head>
        <script src="YalgaarWebRTC.js" type="text/javascript"> </script>
	</head>
</html>

To connect to a Yalgaar client,use following method, it must have valid Client Key.

ConnectToYalgaar({
    ClientKey: 'ClientKey',
    UUID: 'UserID',
    SSL: true,
    EnableFileSharing: true,
    Audio: true, 
    Video: true, 
    Data: true, 
    FileContainer: DivElement,
    Callback: function (acknowledgment) {},
    Error: function (error) {},
    Presence: function (data) {},
    OnStream: function (data) {},
    OnMessage: function (data) {},
    OnOpen: function (data) {},
    OnClose: function (data) {},
    MediaError: function (data, constraint){}
});

Parameter:

  • ClientKey
    • Description: Yalgaar provided authentic client key for project.
    • DataType: String
  • UUID:
    • Description: Any unique user name for user id. UUID is CASE SENSITIVE and only alpha numeric, hyphens, @, underscore allowed and maximum length must be 50.
    • DataType: String
  • SSL
    • Description: Specifies connection is establish with SSL or not.
    • DataType: boolean
  • EnableFileSharing
    • Description: To enable file sharing.
    • DataType: boolean
  • Audio
    • Description: To allow to send and receive audio.
    • DataType: boolean
  • Video
    • Description: To allow to send and receive video
    • DataType: boolean
  • Data
    • Description: To allow to share text data.
    • DataType: boolean
  • FileContainer
    • Description: Specify div element to handle file transferring.
    • DataType: Div Element
  • Callback
    • Description: Called when successfully connected to server.
    • DataType: Callback
  • Error
    • Description: called when system error occurred on during connection.
    • DataType: Callback
  • Presence
    • Description: called when presence events take place such as user join or leave.
    • DataType: Callback
  • Stream
    • Description: Called when stream receive from local or remote connection.
    • DataType: Callback
  • OnMessage
    • Description: Called when text message receive from remote connection.
    • DataType: Callback
  • OnOpen
    • Description: Called when connection successfully established with other client(s).
    • DataType: Callback
  • OnClose
    • Description: Called when client disconnection from other client(s).
    • DataType: Callback
  • MediaError
    • Description: Called when user media devices error occur.
    • DataType: Callback


2 Join User

To connect with other user, use following method.

JoinUser({
RemoteUUID: 'UserId', 
Error: function (Err) {}
});

Parameter:

  • RemoteUUID
    • Description: Remote user id that you want to connect with. UUID is CASE SENSITIVE and only alpha numeric, hyphens, @, underscore allowed and maximum length must be 50.
    • DataType: String
  • Error
    • Description: Called when any error occur during connecting with other user.
    • DataType: Callback


3 Add User

To add user in ongoing conversation/conference, use following method.

AddUser({
    RemoteUUID: 'UserId',
    Error: function (Err) {}
});

Parameter:

  • RemoteUUID
    • Description: Remote user id that you want to add in conversation/conference. UUID is CASE SENSITIVE and only alpha numeric, hyphens, @, underscore allowed and maximum length must be 50.
    • DataType: String
  • Error
    • Description: Called when any error occur during adding user in conversation/conference.
    • DataType: Callback


4 Remove User

To disconnect specific user from conversation, use following method.

RemoveUser({
    RemoteUUID : 'UserId'
});

Parameter:

  • RemoteUUID
    • Description: Remote user id that you want to disconnect user from conversation. UUID is CASE SENSITIVE and only alpha numeric, hyphens, @, underscore allowed and maximum length must be 50.
    • DataType: String


5 Get User List

To get list of all online users list, use following method

UserIDList({
    Callback: function (data) {},
    Error: function (Err) {}
});

Parameter:

  • Callback
    • Description: Called when successfully get user list.
    • DataType: Callback
  • Error
    • Description: Called when any error occur during fetching users list.
    • DataType: Callback


6 Send Text Message

To send text message to all connected user or to specific user, use following method.

SendTextMessage({
    Message: 'This is Yalgaar JavaScript SDK Example',
    RemoteUUID: 'UserId', 
    Callback: function (acknowledgment) {}
});

Parameter:

  • Message
    • Description: Your text Message to be send to conversation
    • DataType: String
  • RemoteUUID
    • Description: This is optional. If you specified than will send message to only that user otherwise will send to all connected users. RemoteUUID is CASE SENSITIVE.
    • DataType: Number
  • Callback
    • Description: Called when Message sent successfully or any error occur.
    • DataType: Callback


7 Send File

To Share file to connected users or with specified connected user, use following method

SendFile({
    RemoteUUID: 'UserId'. 
    Callback: function (acknowledgment) {}
});

Parameter:

  • RemoteUUID
    • Description: This is optional. If you specified then will send file to only that user otherwise will send to all connected users. RemoteUUID is CASE SENSITIVE.
    • DataType: String
  • Callback
    • Description: Called when File sent successfully or any error occur.
    • DataType: Callback


8 Manage Stream

To manage stream audio and video output, use following method.

ManageStream({
    StreamId: 'StreamId',
    Type: "audio/video",
    Disable: true",
    Callback: function (acknowledgment) {}
});

Parameter:

  • StreamId
    • Description: StremId provided in OnStream Event.
    • DataType: String
  • Type
    • Description: Type of stream to disable, must be video or audio.
    • DataType: String
  • Disable
    • Description: True to disable provided type and false to enable it.
    • DataType: boolean
  • Callback
    • Description: Called when successfully enabled or disabled the type or any error occur.
    • DataType: Callback


You can publish/subscribe message like so :

Include Yalgaar WebRTC SDK(yalgaar.js) in your code

<html>
    <head>
        <script src="YalgaarWebRTC.js" type="text/javascript"> </script>
        <script type="text/javascript">
            ConnectToYalgaar({
                ClientKey: 'ClientKey',
                UUID: 'YourUUID',
                SSL: true,
                Audio: true,
                Video: true,
                Data: true,
                Callback: function (ack) {
                    console.log(ack);
                },
                Error: function (err) {
                    console.log(err);
                },
                Presence: function (data) {
                    var user = JSON.parse(data);
                    joinConnection(user.uuid); //Remote UUID
                },
                OnStream: function (data) {
                    console.log(data);
                },
                OnMessage: function (data) {
                    console.log(data);
                },
                OnOpen: function (data) {
                    sendMessage(data.userid); //Remote UUID
                },
                OnClose: function (data) {
                    removeUser(data.userid); //Remote UUID
                },
                MediaError: function (data, constraint) {
                alert(data.name);
                }
            });

            function removeUser(user) {
                RemoveUser({
                    RemoteUUID: user
                });
            }

            function joinConnection(value) {
                JoinUser({
                RemoteUUID: value,
                    Callback: function (ack) {
                        console.log(ack);
                    }
                });
            }

            function sendMessage(remoteID) {
                SendTextMessage({
                    Message: ‘Hello there, We are connected through Yalgaar WebRTC SDK’,
                    RemoteUUID: remoteID
                });
            }
        </script>
    </head>
</html>