Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Room change, logout is implemented for the video streaming.

  • Loading branch information...
commit a8761d1251f45fc9ddc68ee85106c8473558e848 1 parent a03de23
@seyhuns authored
Showing with 18 additions and 9 deletions.
  1. +2 −4 node_server/server.js
  2. +1 −2  public/index.html
  3. +15 −3 public/js/client.js
View
6 node_server/server.js
@@ -51,17 +51,16 @@ io.sockets.on('connection', function (socket) {
}
io.sockets.emit('updateRooms', hash);
};
- var streamInitialize = function (){
- socket.broadcast.to(user.room).emit('streamInitialize', {starterUser: user});
- };
var addUserToRoom = function (){
io.sockets.in(user.room).emit('addUserToRoom', user);
+ socket.broadcast.to(user.room).emit('streamInitialize', {starterUser: user});
};
var editUser = function (newUser, oldUser){
io.sockets.in(user.room).emit('editUser', {"newConfig": newUser, "oldConfig": oldUser});
};
var exitRoom = function (){
io.sockets.in(user.room).emit('exitRoom', user);
+ socket.broadcast.to(user.room).emit('close', user.id);
}
/**
* Update user info.
@@ -81,7 +80,6 @@ io.sockets.on('connection', function (socket) {
socket.join(user.room);
addUserToRoom();
updateRoomsList();
- streamInitialize();
break;
case (user.username !== userConfig.username): // username changed
case (user.typing !== userConfig.typing): // typing changed,
View
3  public/index.html
@@ -8,7 +8,7 @@
<!--[if lt IE 9]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
- <script src="//www.html5cam.com:8080/socket.io/socket.io.js"></script>
+ <script src="//dev.html5cam.com:8080/socket.io/socket.io.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
<script src="js/client.js"></script>
<link rel="stylesheet" type="text/css" href="css/bootstrap.css">
@@ -27,7 +27,6 @@
<form action="" class="pull-right">
<input type="button" id="changeUsername" value="Change Username">
<input type="button" id="changeRoom" value="Change Room">
- <input type="button" id="startVideo" value="Start">
</form>
</div>
</div>
View
18 public/js/client.js
@@ -56,6 +56,8 @@
};
var changeRoom = function(){
user.room = prompt("Room name");
+ $('.remoteVideos').css("opacity", "0");
+ $('.remoteVideos').css("position", "absolute");
socket.emit('setUser', user);
};
var updateRooms = function(rooms){
@@ -115,6 +117,7 @@
if (!started && localStream){
$(".videos").append('<video width="100%" height="100%" id="' + data.streamID + '" autoplay="autoplay"></video>');
remoteVideo = $("#"+data.streamID);
+ remoteVideo.attr("class", "remoteVideos");
createPeerConnection();
pc.addStream(localStream);
started = true;
@@ -157,7 +160,16 @@
if (!started) start();
pc.processSignalingMessage(message);
}
- }
+ };
+ var closeConnection = function(id){
+ if(data.streamID.indexOf(id)!==-1){
+ console.log("1",remoteVideo, pc);
+ remoteVideo.css("opacity", "0");
+ remoteVideo.css("position", "absolute");
+ }else{
+ console.log("2",remoteVideo, pc);
+ }
+ };
if (typeof data.targetUser === "undefined"){
console.log("streamInitializer1", data);
data.targetUser = user;
@@ -169,8 +181,8 @@
interval = setInterval(start, 1000);
}
socket.on('message'+data.streamID, onChannelMessage);
- };
-
+ socket.on('close', closeConnection);
+ }; // end of stream initializer.
try {
navigator.webkitGetUserMedia({audio:true, video:true}, onUserMediaSuccess, onUserMediaError);
console.log("Requested access to local media with new syntax.");
Please sign in to comment.
Something went wrong with that request. Please try again.