Guest User

Untitled

a guest
May 27th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1.  
  2.  
  3. function ScoreNetwork(score)
  4. {
  5. this.ws = null;
  6. this.data = null;
  7. this.score = score;
  8. this.initialize = function()
  9. {
  10. this.ws = new WebSocket('ws://localhost:7000');
  11. this.ws.onmessage = function(event)
  12. {
  13. this.data = JSON.parse(event.data);
  14. this.score.changeMinimum(this.getLimit());
  15. }
  16. this.ws.onclose = function()
  17. {
  18. console.log("Welcome to our world");
  19. }
  20. }
  21. //Return the mininum score to submit score to database.
  22. this.getLimit = function()
  23. {
  24. if (this.data.status == true)
  25. {
  26. return this.data.scores[99];
  27. }
  28. return false;
  29. }
  30. this.transmitScore = function()
  31. {
  32. var message = {
  33. name = "kiba",
  34. points = this.score.points,
  35. }
  36. this.ws.send(JSON.parse(message));
  37. }
  38. }
Add Comment
Please, Sign In to add comment