]> git.example.dev Git - binbsis50.git/commitdiff
removed `getstatus` event
authorLuigi Pinca <luigipinca@gmail.com>
Tue, 5 Apr 2016 15:22:39 +0000 (17:22 +0200)
committerLuigi Pinca <luigipinca@gmail.com>
Tue, 5 Apr 2016 16:28:50 +0000 (18:28 +0200)
lib/rooms.js
lib/sparks.js
public/js/app.js

index d7cca0411c49c5c9fe6a0cf2322311ccb1cd0108..1f9658132747360cb79f44aeb9e5d90202bc2fab 100644 (file)
@@ -168,7 +168,17 @@ Room.prototype.addUser = function(spark, loggedin) {
 
   // Broadcast new user event
   primus.send('updateoverview', this.roomname, this.totusers);
-  spark.send('ready', usersData, this.trackscount, nickname, loggedin);
+  spark.send('ready', {
+    trackscount: this.trackscount,
+    usersData: usersData,
+    nickname: nickname,
+    loggedin: loggedin,
+    state: {
+      previewUrl: this.previewUrl,
+      timeleft: this.songtimeleft,
+      status: this.status
+    }
+  });
   primus.room(this.roomname).except(spark.id).send('newuser', nickname, usersData);
 };
 
@@ -560,18 +570,6 @@ Room.prototype.sendPlayTrack = function() {
   setTimeout(this.sendTrackInfo.bind(this), 30000);
 };
 
-/**
- * Send the room status to the client that asked for it.
- */
-
-Room.prototype.sendStatus = function(callback) {
-  callback({
-    status: this.status,
-    timeleft: this.songtimeleft,
-    previewUrl: this.previewUrl
-  });
-};
-
 /**
  * Send the track info to all connected clients.
  */
index 6d63279d5023551164b6c699cf0d8ff193b85013..91dbdd8599754ce2f081ae7895af6f3a140eb7f7 100644 (file)
@@ -160,11 +160,6 @@ var joinRoom = function(room, spark) {
       room.onChatMessage(msg, spark, to);
     }
   });
-  spark.on('getstatus', function(callback) {
-    if (isFunction(callback)) {
-      room.sendStatus(callback);
-    }
-  });
   spark.on('guess', function(guess) {
     if (isString(guess)) {
       room.onGuess(spark, guess);
index be798fc09e47f7494c19035de086a272cb375a49..b5156e8c1c139f02fe7a2ec3b12bbfb558bb382f 100644 (file)
   };
 
   // Successfully joined the room
-  var ready = function(usersData, trackscount, username, loggedin) {
-    nickname = username;
+  var ready = function(data) {
+    nickname = data.nickname;
 
-    if (!loggedin) {
+    if (!data.loggedin) {
       document.cookie = 'nickname=' + nickname + ';path=/;';
     } else {
       subscriber = true;
     }
 
     $modal.modal('hide').empty();
-    $('#total-tracks span').text(trackscount);
+    $('#total-tracks span').text(data.trackscount);
 
     var $entry = $('<span class="join">' + nickname + ' joined the game</span>');
     addChatEntry($entry);
-    updateUsers(usersData);
+    updateUsers(data.usersData);
 
     $messagebox.on('keydown', function(event) {
       if (event.keyCode === 13) {
     primus.on('trackinfo', addTrackInfo);
     primus.on('updateusers', updateUsers);
     primus.on('userleft', userLeft);
-    primus.send('getstatus', setStatus);
+
+    setStatus(data.state);
   };
 
   // Show the number of players inside each room