changed message format master
[php-js-websockets.git] / index.php
blob:a/index.php -> blob:b/index.php
--- a/index.php
+++ b/index.php
@@ -33,13 +33,13 @@
               socket.onmessage = function(msg){
                  message('<p class="message">Received: '+msg.data);
                  var msgdata = msg.data;
-                 var _message = msgdata.split ('$');
-                 var cmd = _message[0];
-                 var msg = _message[1];
-                 console.log ('CMD: '+cmd);
-                 console.log ('MSG: '+msg);
-                 if ( cmd == "changebackground" ) {
-                    $("body").css("background-color", msg );
+                 var _message = msgdata.split (':');
+                 var action = _message[0];
+                 var params = _message[1];
+                 console.log ('ACTION: '+action);
+                 console.log ('PARAMS: '+params);
+                 if ( action == "changebackground" ) {
+                    $("body").css("background-color", params );
                  }
               }
 
@@ -141,7 +141,7 @@
         <div id="chatLog">
         </div>
         <p id="examples">e.g. try 'ping'</p>
-        <input id="text" type="text" value="chat|changebackground$red" />
+        <input id="text" type="text" value="do|changebackground:red" />
         <!--button id="disconnect">Disconnect</button-->
 </div>
 <?php $url = urlencode ("http://".$_SERVER['HTTP_HOST']."/?code=".session_id ()); ?>

comments