reinit project

This commit is contained in:
artyom.abubakirov committed 2018-05-31 00:21:10 +05:00
1 parent bd5f2a6591
commit 67fcfc8beb
17 files changed
+70 -1056

No files matched your search

Regular → Executable
+58 -43
View File
@@ -14,60 +14,68 @@
*/
//var ws = new WebSocket('wss://' + location.host + '/one2many');
var video;
var webRtcPeer;
var socket;
var autoView = true;
var room;
function onError(msg){
console.log(msg);
}
$(function() {
socket = io();
console = new Console();
video = $('#video')[0];
room = $('#roomName');
let url_string = window.location.href;
let url = new URL(url_string);
room = url.searchParams.get('room');
console.log(room);
socket = io('https://kurento.fishrungames.com/');
$('#call').on('click', function(e) { presenter(); e.preventDefault(); } );
$('#viewer').on('click', function(e) { viewer(); e.preventDefault(); } );
$('#terminate').on('click', function(e) { stop(); e.preventDefault();} );
socket.on('connect', function(){
console.log('Connected to socket');
socket.on('connect', function(){
console.log('Connected to socket');
socket.emit('subscribeToStream', currentRoom());
socket.emit('subscribeToStream', currentRoom());
});
socket.on('disconnect', function(){
console.log('Disconnected from socket');
dispose();
});
socket.on('presenterResponse', function(data) {
presenterResponse(data);
});
socket.on('viewerResponse', function(data) {
viewerResponse(data);
});
socket.on('stopCommunication', function(data) {
console.log('stopCommunication');
dispose();
});
socket.on('iceCandidate', function(data) {
webRtcPeer.addIceCandidate(data.candidate)
});
socket.on('streamStarted', function(data) {
if (autoView) {
viewer();
}
});
});
socket.on('disconnect', function(){
console.log('Disconnected from socket');
dispose();
});
socket.on('presenterResponse', function(data) {
presenterResponse(data);
});
socket.on('viewerResponse', function(data) {
viewerResponse(data);
});
socket.on('stopCommunication', function(data) {
console.log('stopCommunication');
dispose();
});
socket.on('iceCandidate', function(data) {
webRtcPeer.addIceCandidate(data.candidate)
});
socket.on('streamStarted', function(data) {
if (autoView) {
viewer();
}
});
});
function presenterResponse(message) {
if (message.response != 'accepted') {
var errorMsg = message.message ? message.message : 'Unknown error';
@@ -88,10 +96,6 @@ function viewerResponse(message) {
}
}
function onError(obj) {
console.log(obj);
}
function presenter() {
if (!webRtcPeer) {
showSpinner(video);
@@ -127,7 +131,18 @@ function viewer() {
var options = {
remoteVideo: video,
onicecandidate : onIceCandidate
onicecandidate : onIceCandidate,
configuration: {
iceServers:[
{
urls: 'turn:numb.viagenie.ca',
credential: '170988abC',
password: '170988abC',
username: 'wow_123@bk.ru'
}
]
}
};
webRtcPeer = kurentoUtils.WebRtcPeer.WebRtcPeerRecvonly(options, function(error) {
@@ -193,7 +208,7 @@ function hideSpinner() {
}
function currentRoom() {
return $('#roomName').val();
return room;
}
/**