Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var Lynx = require('lynx');
- function _onError(err) {
- console.log(err);
- }
- var _options = {
- host : 'sfast-grafana.cloudapp.net',
- port : 8125
- };
- var metrics = new Lynx(_options.host, _options.port, {on_error: _onError});
- var timer = null;
- function BlotMetrics(userId) {
- var _roomId = null,
- _gameId = null;
- // ** calling findRoom() from room if user can play
- this.findRoom = function(roomType) {
- metrics.increment("bcclub.find_room");
- metrics.set("bcclub.findRoomType", roomType);
- };
- // ** calling createRoom() from room when stack created rooms
- this.createRoom = function(roomId) {
- metrics.increment("bcclub.new_room_counter");
- };
- // ** calling startUserGame() from game when game is starting
- this.startUserGame = function(gameId) {
- _gameId = gameId;
- metrics.set("bcclub.startgame_set", _gameId);
- metrics.increment("bcclub.startgame_counter");
- };
- // ** calling endUserGame() from game when game is finished
- this.endUserGame = function() {
- if(!_gameId) {
- metrics.increment("bcclub.endgame_null_gameid");
- return;
- }
- metrics.increment("bcclub.endgame_counter");
- metrics.set("bcclub.endgame_set", _gameId);
- _gameId = null;
- };
- // ** calling recconenctRoom() from room when welcome rooom active
- this.recconenctRoom = function() {
- metrics.set("bcclub.reconnectRoom");
- metrics.increment("bcclub.reconnect_room_counter");
- };
- // ** calling recconenctRoom() from socket when user will leave fromgame
- this.leaveUserGame = function() {
- if(!_gameId) {
- metrics.increment("bcclub.leavegame_null_gameid");
- return;
- }
- metrics.increment("bcclub.leavegame_counter");
- metrics.set("bcclub.leavegame_set", _gameId);
- if(timer) {
- timer.stop();
- timer = null;
- }
- _gameId = null;
- };
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement