mirror of https://github.com/calzoneman/sync.git
Add usercount indicator
This commit is contained in:
parent
5ca419d3e3
commit
259c72e7da
|
@ -208,6 +208,7 @@ Channel.prototype.userJoin = function(user) {
|
|||
if(user.name != "") {
|
||||
this.broadcastNewUser(user);
|
||||
}
|
||||
this.updateUsercount();
|
||||
// Set the new guy up
|
||||
this.sendPlaylist(user);
|
||||
this.sendUserlist(user);
|
||||
|
@ -220,6 +221,7 @@ Channel.prototype.userJoin = function(user) {
|
|||
// Called when a user leaves the channel
|
||||
Channel.prototype.userLeave = function(user) {
|
||||
this.users.splice(this.users.indexOf(user), 1);
|
||||
this.updateUsercount();
|
||||
if(user.name != "") {
|
||||
this.sendAll('userLeave', {
|
||||
name: user.name
|
||||
|
@ -506,6 +508,12 @@ Channel.prototype.sendUserlist = function(user) {
|
|||
user.socket.emit('userlist', users)
|
||||
}
|
||||
|
||||
Channel.prototype.updateUsercount = function() {
|
||||
this.sendAll('usercount', {
|
||||
count: this.users.length
|
||||
});
|
||||
}
|
||||
|
||||
// Send the play queue
|
||||
Channel.prototype.sendPlaylist = function(user) {
|
||||
user.socket.emit('playlist', {
|
||||
|
|
|
@ -42,6 +42,10 @@ function initCallbacks() {
|
|||
}
|
||||
});
|
||||
|
||||
socket.on('usercount', function(data) {
|
||||
$('#usercount').text(data.count + " connected users");
|
||||
});
|
||||
|
||||
socket.on('chatMsg', function(data) {
|
||||
var div = formatChatMessage(data);
|
||||
$('#messagebuffer')[0].appendChild(div);
|
||||
|
|
|
@ -54,6 +54,7 @@
|
|||
</div>
|
||||
<div class="row" style="margin-top: 20px;">
|
||||
<div class="span6">
|
||||
<p id="usercount"></p>
|
||||
<div id="userlist">
|
||||
</div>
|
||||
<div id="messagebuffer">
|
||||
|
|
Loading…
Reference in New Issue