OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

How to find your own connection Id in client Opentok

  • Thread starter Thread starter dhiraj uchil
  • Start date Start date
D

dhiraj uchil

Guest
how can a client find its own connectionId when it connects to a session?

here is my client code I tried listening to streamcreated but it gives back id of all the streams when they connect.

Code:
function initializeSession() {
  var session = OT.initSession(apiKey, sessionId);

  session.on('streamCreated', function streamCreated(event) {



    var subscriberOptions = {
      insertMode: 'append',
      width: '100%',
      height: '100%'
    };
    session.subscribe(event.stream, 'subscriber', subscriberOptions, handleError);
  });

  session.on('sessionDisconnected', function sessionDisconnected(event) {
    console.log('You were disconnected from the session.', event.reason);
  });


  var publisherOptions = {
    insertMode: 'append',
    width: '100%',
    height: '100%',
    name: pubname,
    style: { nameDisplayMode: "auto" }
  };
  var publisher = OT.initPublisher('publisher', publisherOptions, handleError);

  session.connect(token, function callback(error) {
    if (error) {
      handleError(error);
    } else {
      session.publish(publisher, handleError);
    }
  });
}

getData();
initializeSession();

<p>how can a client find its own connectionId when it connects to a session?</p>

<p>here is my client code
I tried listening to streamcreated but it gives back id of all the streams when they connect.</p>

<pre><code>function initializeSession() {
var session = OT.initSession(apiKey, sessionId);

session.on('streamCreated', function streamCreated(event) {



var subscriberOptions = {
insertMode: 'append',
width: '100%',
height: '100%'
};
session.subscribe(event.stream, 'subscriber', subscriberOptions, handleError);
});

session.on('sessionDisconnected', function sessionDisconnected(event) {
console.log('You were disconnected from the session.', event.reason);
});


var publisherOptions = {
insertMode: 'append',
width: '100%',
height: '100%',
name: pubname,
style: { nameDisplayMode: "auto" }
};
var publisher = OT.initPublisher('publisher', publisherOptions, handleError);

session.connect(token, function callback(error) {
if (error) {
handleError(error);
} else {
session.publish(publisher, handleError);
}
});
}

getData();
initializeSession();
</code></pre>
 

Latest posts

Top