You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
847 B

  1. var socket = io();
  2. /*Initializing the connection with the server via websockets */
  3. socket.emit('liveMessage', "true");
  4. socket.on("jsonHoneycomb",function(message){
  5. /*
  6. When server sends data to the client it will trigger "message" event on the client side , by
  7. using socket.on("message") , one cna listen for the ,message event and associate a callback to
  8. be executed . The Callback function gets the dat sent from the server
  9. */
  10. console.log("Message from the server arrived")
  11. var honeyCells = JSON.parse(message);
  12. if( honeyCells.constructor === Array){
  13. for (var i = 0; i < honeyCells.length; i++) {
  14. populateHoneycomb( honeyCells[i], i );
  15. };
  16. }else{
  17. populateHoneycomb( honeyCells , 0);
  18. }
  19. socket.emit('ackMessage', "true");
  20. });