-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue #2: wrong naming #5
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<!DOCTYPE HTML> | ||
<html lang="en"> | ||
<head> | ||
<title>Instructor's dashboard</title> | ||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> | ||
<meta http-equiv="Content-Language" content="en-us"> | ||
|
||
<script type="text/javascript" src="/third_party/jquery-2.1.0.min.js"></script> | ||
<script type="text/javascript" src="/third_party/peer.min.js"></script> | ||
<script type="text/javascript" src="/socket.io/socket.io.js"></script> | ||
<script type="text/javascript" src="../app.js"></script> | ||
|
||
<link rel="stylesheet" type="text/css" media="screen, print, handheld" href="/styles/styles.css" /> | ||
|
||
<script> | ||
$(function() { | ||
var is_admin = true, | ||
pittPeer = APP.newPP(is_admin); | ||
}); | ||
</script> | ||
</head> | ||
|
||
<body> | ||
<h1>Instructor's view</h1> | ||
<h3>Current mode: <span id="current_mode"></span></h3> | ||
<input type="button" id="broadcast" value="Start broadcasting"><br> | ||
or change mode to: | ||
<input type="button" id="bMode" value="Few" /> | ||
|
||
<div id="main"> | ||
You are: <span id="you_are"> </span> | ||
<div id="list_users"></div> | ||
</div> | ||
</body> | ||
|
||
</html> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,36 @@ | ||
<!DOCTYPE HTML> | ||
<!-- vim: set ts=2 et:--> | ||
<html lang="en"> | ||
<head> | ||
<title>peerjs playground</title> | ||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> | ||
<meta http-equiv="Content-Language" content="en-us"> | ||
<title>Student's dashboard</title> | ||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> | ||
<meta http-equiv="Content-Language" content="en-us"> | ||
|
||
<script type="text/javascript" src="/third_party/jquery-2.1.0.min.js"></script> | ||
<script type="text/javascript" src="/third_party/peer.min.js"></script> | ||
<script type="text/javascript" src="/socket.io/socket.io.js"></script> | ||
<script type="text/javascript" src="/app.js"></script> | ||
<script type="text/javascript" src="/third_party/jquery-2.1.0.min.js"></script> | ||
<script type="text/javascript" src="/third_party/peer.min.js"></script> | ||
<script type="text/javascript" src="/socket.io/socket.io.js"></script> | ||
<script type="text/javascript" src="../app.js"></script> | ||
|
||
<link rel="stylesheet" type="text/css" media="screen, print, handheld" href="/styles/styles.css" /> | ||
<link rel="stylesheet" type="text/css" media="screen, print, handheld" href="/styles/styles.css" /> | ||
|
||
<script> | ||
$(function() { | ||
var is_admin = false, | ||
el_my_video = $('#my-video'), | ||
el_their_video = $('#container-their-video'), | ||
pittPeer = APP.newPP(is_admin, el_my_video, el_their_video); | ||
}); | ||
</script> | ||
|
||
<div id="main"> | ||
You are: <span id="you_are"> </span> | ||
<div id="list_users"> </div> | ||
<div id="video_chat_area"> | ||
<div id="local_video"> <video id="my-video" muted="true" autoplay></video> </div> | ||
<div id="container-their-video" class=""> </div> | ||
</div> | ||
</div> | ||
<script> | ||
$(function() { | ||
var is_admin = false, | ||
el_my_video = $('#my-video'), | ||
el_their_video = $('#container-their-video'), | ||
pittPeer = APP.newPP(is_admin, el_my_video, el_their_video); | ||
}); | ||
</script> | ||
</head> | ||
|
||
<body> | ||
<h1>Students's view</h1> | ||
<div id="main"> | ||
<p>You are: <span id="you_are"> </span></p> | ||
<div id="list_users"> </div> | ||
<div id="video_chat_area"> | ||
<div id="local_video"> <video id="my-video" muted="true" autoplay></video> </div> | ||
<div id="container-their-video" class=""> </div> | ||
</div> | ||
</div> | ||
</body> | ||
|
||
</html> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,13 @@ | ||
// vim: set ts=2 et: | ||
|
||
var NOT_WORKING = 0; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't want to pollute the global name space. Notice how I try to put all related logic in its own I'd add those in the variable definition within the newPP function in |
||
var BROADCAST_MODE = 2; | ||
var GROUP_MODE = 3; | ||
|
||
APP.newPP = function(isAdmin, el_my_video, el_their_video) { | ||
var my_id, iface = {}, | ||
socket = io.connect('http://localhost:8111'), | ||
mode = NOT_WORKING, | ||
v_chat; // All the video chat logic | ||
|
||
function set_click_mode_change() { | ||
|
@@ -11,27 +16,45 @@ APP.newPP = function(isAdmin, el_my_video, el_their_video) { | |
currVal = b.val(), | ||
newVal = (currVal === "All") ? "Few" : "All"; | ||
|
||
b.attr('value', newVal); | ||
socket.emit('mode_change', currVal); | ||
b.attr('value', newVal); | ||
socket.emit('mode_change', currVal); | ||
mode = (currVal === "All") ? BROADCAST_MODE : GROUP_MODE; | ||
show_mode("#current_mode"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not just adding this line in this function: Also, set a variable within the module to point to the id of the element where we will drop |
||
}); | ||
} | ||
|
||
function show_mode(element) { | ||
console.log("changing mode!") | ||
$(element).text( | ||
(mode === BROADCAST_MODE) ? "Broadcasting" : "Working in groups" | ||
) | ||
} | ||
|
||
function set_click_start_broadcasting() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In general, do not send dead code in a PR. |
||
$("#broadcast").click(function() { | ||
|
||
}) | ||
} | ||
|
||
function for_admin() { | ||
console.log("Admin mode."); | ||
console.log("Admin mode."); | ||
socket.on('list_rooms', function(listRooms) { | ||
console.log(listRooms); | ||
// console.log(listRooms); | ||
var r = $('#list_users'); | ||
r.empty(); | ||
Object.keys(listRooms).forEach(function(name, i, a) { | ||
r.append("<ul>" + name); | ||
listRooms[name].forEach(function(user, _i, _a) { | ||
r.append("<li>" + user); | ||
r.append("<li>" + user + "</li>"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In html5, tag closing for some tags is optional. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wow, I had no idea! |
||
}); | ||
r.append("</ul>"); | ||
}); | ||
}); | ||
|
||
set_click_mode_change(); | ||
socket.emit('mode_change', "All"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are we doing a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Student's code prepares their browsers for streaming when they receive So basically all I want to do is to set to single room mode as soon as teacher appears online. |
||
mode = BROADCAST_MODE; | ||
show_mode("#current_mode"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same thing as before, it is more decoupled if we do: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed. Except that I think having current mode set in a variable in a numeric format is a good idea. |
||
} | ||
|
||
function for_peer() { | ||
|
@@ -69,6 +92,7 @@ APP.newPP = function(isAdmin, el_my_video, el_their_video) { | |
}); | ||
}); | ||
|
||
// XXX: this never happens? | ||
socket.on('mode_change', function(data) { | ||
console.log('mode_change: ' + data); | ||
}); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,8 @@ | |
} | ||
|
||
#you_are { | ||
padding: 10px; | ||
padding: 5px; | ||
background-color: #EEE; | ||
} | ||
|
||
#list_users { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,8 +4,11 @@ module.exports = function() { | |
var iface = {}, // intarface too all this logic | ||
def_room = "room1", | ||
admins = {}, | ||
peers = {}, rooms = {}, ppr = 2; // # People per room | ||
peers = {}, | ||
rooms = {}, | ||
ppr = 2; // # People per room | ||
|
||
// bunch of getters and setters for .peers, .rooms and .ppr | ||
iface.peers = function(_) { | ||
if (!arguments.length) return peers; | ||
peers = _; | ||
|
@@ -65,20 +68,27 @@ module.exports = function() { | |
io.sockets.on('connection', function (socket) { | ||
|
||
socket.on('newadmin', function (id) { | ||
console.log("newadmin1", rooms) | ||
socket.peer_id = id; | ||
socket.is_admin = true; | ||
admins[id] = socket; | ||
//io.sockets.emit('list_rooms', rooms); | ||
io.sockets.emit('list_rooms', rooms); | ||
console.log("newadmin2", rooms) | ||
}); | ||
|
||
socket.on('newpeer', function (id) { | ||
console.log("newpeer1", rooms) | ||
socket.peer_id = id; | ||
socket.is_admin = false; | ||
peers[id] = socket; | ||
rooms[def_room].push(id); | ||
io.sockets.emit('update_list', Object.keys(peers), 'new'); | ||
io.sockets.emit('list_rooms', rooms); | ||
console.log("newpeer2", rooms) | ||
}); | ||
|
||
socket.on('mode_change', function(newMode) { | ||
console.log("New mode:", newMode) | ||
if (newMode === 'Few') { | ||
multiRooms(); | ||
updateClientsLists('few'); | ||
|
@@ -91,14 +101,18 @@ module.exports = function() { | |
}); | ||
|
||
socket.on('disconnect', function() { | ||
console.log("disconnect1", rooms) | ||
delete peers[socket.peer_id]; | ||
delete admins[socket.peer_id]; | ||
update_rooms(socket.peer_id); | ||
if (!socket.is_admin) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hopefully introduction of a new attribute is an acceptable fix for the bug. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeap, good catch! |
||
update_rooms(socket.peer_id); | ||
} | ||
|
||
io.sockets.emit('update_list', Object.keys(peers), 'gone'); | ||
io.sockets.emit('list_rooms', rooms); | ||
console.log("disconnect2", rooms) | ||
console.log("Peer gone: " + socket.peer_id); | ||
console.log(peers); | ||
// console.log(peers); | ||
}); | ||
}); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, after this first review, I'd like to highlight what I think are the important things we have
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this (../app.js)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I honestly don't remember why I had changed that! Reverted.