<script src="http://static.opentok.com/webrtc/v2.0/js/TB.min.js" ></script> <script src="https://static.opentok.com/webrtc/v2.0/js/TB.min.js" ></script> <script type="text/javascript" src="http://code.jquery.com/jquery-1.7.1.min.js"></script> <script type="text/javascript"> var publisher; var session; var apiKey = "44686132"; var sessionId = "1_MX40NDY4NjEzMn4xMjcuMC4wLjF-V2VkIE1hciAxOSAyMDo1ODozNyBQRFQgMjAxNH4wLjAzMTA3MTAwN34"; var token = document.getElementById("<%= hdn1.ClientID %>").value; publisher = TB.initPublisher(apiKey); session = TB.initSession(sessionId); session.connect(apiKey, token); session.addEventListener("sessionConnected", sessionConnectedHandler); session.addEventListener("streamCreated", streamCreatedHandler); function sessionConnectedHandler(event) { alert("sessionConnectedHandler"); subscribeToStreams(event.streams); session.publish(publisher); } function subscribeToStreams(streams) { if (stream.connection.connectionId != session.connection.connectionId) { //var streams = event.streams; for (var i = 0; i < streams.length; i++) { var stream = streams[i]; var newDivId = "streams" + stream[i].streamId; var newDiv = $('<div />', { id: newDivId }); $('body').append(newDiv); if (stream.connection.connectionId != session.connection.connectionId) { session.subscribe(stream[i], newDivId); } } } } function streamCreatedHandler(event) { subscribeToStreams(event.streams); } </script>
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)