Advertisement
RowanHarley

Untitled

Jun 17th, 2016
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // The Call
  2. var move = messages.movement.build(conn.id, conn.snake.direction.x, conn.snake.direction.y);
  3. var dir = messages.direction.build(conn.id, conn.snake.direction);
  4. try{
  5.     broadcast(dir);
  6. }catch(e){
  7.     console.log("[ERROR] " + e);
  8. }
  9. try{
  10.     broadcast(move);
  11. }catch(e){
  12.     console.log("[ERROR] " + e);
  13. }
  14.  
  15. // The Function
  16. function broadcast(data){
  17.     /* "use strict";
  18.     for(let client in clients){
  19.         if(client != null){
  20.             client.send(data, {binary: true});
  21.         }
  22.     } */
  23.     for(var i = 0; i < clients.length; i++){
  24.         if(clients[i]){
  25.             clients[i].send(data, {binary:true});
  26.         }
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement