Advertisement
Guest User

Untitled

a guest
Mar 24th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.97 KB | None | 0 0
  1. var Lynx = require('lynx');
  2. function _onError(err) {
  3. console.log(err);
  4. }
  5. var _options = {
  6. host : 'sfast-grafana.cloudapp.net',
  7. port : 8125
  8. };
  9. var metrics = new Lynx(_options.host, _options.port, {on_error: _onError});
  10. var timer = null;
  11. function BlotMetrics(userId) {
  12. var _roomId = null,
  13. _gameId = null;
  14.  
  15.  
  16. // ** calling findRoom() from room if user can play
  17. this.findRoom = function(roomType) {
  18. metrics.increment("bcclub.find_room");
  19. metrics.set("bcclub.findRoomType", roomType);
  20. };
  21.  
  22. // ** calling createRoom() from room when stack created rooms
  23. this.createRoom = function(roomId) {
  24. metrics.increment("bcclub.new_room_counter");
  25. };
  26.  
  27. // ** calling startUserGame() from game when game is starting
  28. this.startUserGame = function(gameId) {
  29. _gameId = gameId;
  30. metrics.set("bcclub.startgame_set", _gameId);
  31. metrics.increment("bcclub.startgame_counter");
  32. };
  33.  
  34. // ** calling endUserGame() from game when game is finished
  35. this.endUserGame = function() {
  36. if(!_gameId) {
  37. metrics.increment("bcclub.endgame_null_gameid");
  38. return;
  39. }
  40.  
  41. metrics.increment("bcclub.endgame_counter");
  42. metrics.set("bcclub.endgame_set", _gameId);
  43. _gameId = null;
  44. };
  45.  
  46.  
  47. // ** calling recconenctRoom() from room when welcome rooom active
  48. this.recconenctRoom = function() {
  49. metrics.set("bcclub.reconnectRoom");
  50. metrics.increment("bcclub.reconnect_room_counter");
  51. };
  52.  
  53.  
  54. // ** calling recconenctRoom() from socket when user will leave fromgame
  55. this.leaveUserGame = function() {
  56. if(!_gameId) {
  57. metrics.increment("bcclub.leavegame_null_gameid");
  58. return;
  59. }
  60.  
  61. metrics.increment("bcclub.leavegame_counter");
  62. metrics.set("bcclub.leavegame_set", _gameId);
  63. if(timer) {
  64. timer.stop();
  65. timer = null;
  66. }
  67. _gameId = null;
  68. };
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement