## GameMsgGenerator constructor

Creates a new instance of GameMsgGenerator

@param {GameServer} gameServer Reference to the Game Server where
the generator is instantiated
761432
function GameMsgGenerator(gameServer) {
    this.session = gameServer.session;
    this.sender = gameServer.name;
    this.stage = null;
}
922236
function Stager(stateObj) {

        // ## Properties

        /**
         * #### Stager.steps
         *
         * Step object container
         *
         * key: step ID,  value: step object
         *
         * @see Stager.addStep
         */
        this.steps = {};

        /**
         * #### Stager.stages
         *
         * Stage object container
         *
         * key: stage ID,  value: stage object
         *
         * Stage aliases are stored the same way, with a reference to
         * the original stage object as the value.
         *
         * @see Stager.addStage
         */
        this.stages = {};

        /**
         * #### Stager.sequence
         *
         * Sequence block container
         *
         * Stores the game plan in 'simple mode'.
         *
         * @see Stager.gameover
         * @see Stager.next
         * @see Stager.repeat
         * @see Stager.loop
         * @see Stager.doLoop
         */
        this.sequence = [];

        /**
         * #### Stager.generalNextFunction
         *
         * General next-stage decider function
         *
         * Returns the id of the next game step.
         * Available only when nodegame is executed in _flexible_ mode.
         *
         * @see Stager.registerGeneralNext
         */
        this.generalNextFunction = null;

        /**
         * #### Stager.nextFunctions
         *
         * Per-stage next-stage decider function
         *
         * key: stage ID,  value: callback function
         *
         * Stores functions to be called to yield the id of the next
         * game stage for a specific previous stage.
         *
         * @see Stager.registerNext
         */
        this.nextFunctions = {};

        /**
         * #### Stager.defaultStepRule
         *
         * Default step-rule function
         *
         * This function decides whether it is possible to proceed to
         * the next step/stage. If a step/stage object defines a
         * `steprule` property, then that function is used instead.
         *
         * @see Stager.getDefaultStepRule
         * @see GamePlot.getStepRule
         */
        this.setDefaultStepRule();

        /**
         * #### Stager.defaultGlobals
         *
         * Defaults of global variables
         *
         * This map holds the default values of global variables. These
         * values are overridable by more specific version in step and
         * stage objects.
         *
         * @see Stager.setDefaultGlobals
         * @see GamePlot.getGlobal
         */
        this.defaultGlobals = {};

        /**
         * #### Stager.defaultProperties
         *
         * Defaults of properties
         *
         * This map holds the default values of properties. These values
         * are overridable by more specific version in step and stage
         * objects.
         *
         * @see Stager.setDefaultProperties
         * @see GamePlot.getProperty
         */
        this.defaultProperties = {};

        /**
         * #### Stager.onInit
         *
         * Initialization function
         *
         * This function is called as soon as the game is instantiated,
         * i.e. at stage 0.0.0.
         *
         * Event listeners defined here stay valid throughout the whole
         * game, unlike event listeners defined inside a function of the
         * gamePlot, which are valid only within the specific function.
         */
        this.onInit = null;

        /**
         * #### Stager.onGameover
         *
         * Cleaning up function
         *
         * This function is called after the last stage of the gamePlot
         * is terminated.
         */
        this.onGameover = null;

        /**
         * #### Stager.blocks
         *
         * Array of blocks as they in the order they were added to the stager
         */
        this.blocks = [];

        /**
         * #### Stager.blocksIds
         *
         * Map block-id to block-position in the blocks array
         *
         * @see blocks
         */
        this.blocksIds = {};

        /**
         * #### Stager.unfinishedBlocks
         *
         * List of all Blocks stager might still modify
         */
        this.unfinishedBlocks = [];

        /**
         * #### Stager.finalized
         *
         * Flag indicating if the hierarchy of has been set
         *
         * Indicates if the hierarchy of stages and steps has been set.
         */
        this.finalized = false;

        /**
         * #### Stager.currentType
         *
         * Name of the stage currently worked with in building hierarchy
         */
        this.currentType = blockTypes.BLOCK_DEFAULT;

        /**
         * #### Stager.currentBlockType
         *
         * Indicates what type of Block was added last
         */
        this.currentBlockType = blockTypes.BLOCK_DEFAULT;

        /**
         * #### Stager.toSkip
         *
         * List of stages and steps to skip when building the sequence
         */
        this.toSkip = {
            stages: {},
            steps: {}
        };

        /**
         * #### Stager.defaultCallback
         *
         * Default callback assigned to a step if none is provided
         */
        this.defaultCallback = Stager.defaultCallback;

        /**
         * #### Stager.cacheReset
         *
         * Cache used to reset the state of the stager after finalization
         */
        this.cacheReset = {
            unfinishedBlocks: []
        };

        /**
         * #### Stager.log
         *
         * Default standard output. Override to redirect.
         */
        this.log = console.log;

        // Set the state if one is passed.
        if (stateObj) {
            if ('object' !== typeof stateObj) {
                throw new TypeError('Stager: stateObj must be object.');
            }
            this.setState(stateObj);
        }
        else {
            // Add first block.
            this.stageBlock(blockTypes.BLOCK_DEFAULT, 'linear');
        }
    }
187770
private Expression generateMsgGroupVariable(MsgFallbackGroupNode node, String tmpVarName) {
    checkState(node.numChildren() == 2);

    // Generate the goog.getMsg calls for all children.
    GoogMsgCodeGenInfo primaryCodeGenInfo =
        genGoogGetMsgCallHelper(buildGoogMsgVarNameHelper(node.getChild(0)), node.getChild(0));
    GoogMsgCodeGenInfo fallbackCodeGenInfo =
        genGoogGetMsgCallHelper(buildGoogMsgVarNameHelper(node.getChild(1)), node.getChild(1));

    // Declare a temporary variable to hold the getMsgWithFallback() call so that we can apply any
    // MessageFormats from any of the fallbacks.  This is also the variable name that we return to
    // the caller.
    Expression selectedMsg =
        VariableDeclaration.builder(tmpVarName)
            .setRhs(
                Expression.dottedIdNoRequire("goog.getMsgWithFallback")
                    .call(primaryCodeGenInfo.googMsgVar, fallbackCodeGenInfo.googMsgVar))
            .build()
            .ref();

    // We use id() here instead of using the corresponding code chunks because the stupid
    // jscodebuilder system causes us to regenerate the msg vars multiple times because it doesn't
    // detect that they were already generated.
    // TODO(b/33382980): clean this up
    Expression isPrimaryMsgInUse =
        Expression.id(tmpVarName).doubleEquals(Expression.id(primaryCodeGenInfo.googMsgVarName));
    translationContext.soyToJsVariableMappings().setIsPrimaryMsgInUse(node, isPrimaryMsgInUse);
    if (primaryCodeGenInfo.placeholders == null && fallbackCodeGenInfo.placeholders == null) {
      // all placeholders have already been substituted, just return
      return selectedMsg;
    }
    // Generate the goog.i18n.MessageFormat calls for child plural/select messages (if any), each
    // wrapped in an if-block that will only execute if that child is the chosen message.
    Statement condition;
    if (primaryCodeGenInfo.placeholders != null) {
      ConditionalBuilder builder =
          Statement.ifStatement(
              selectedMsg.doubleEquals(primaryCodeGenInfo.googMsgVar),
              selectedMsg.assign(getMessageFormatCall(primaryCodeGenInfo)).asStatement());
      if (fallbackCodeGenInfo.placeholders != null) {
        builder.setElse(
            selectedMsg.assign(getMessageFormatCall(fallbackCodeGenInfo)).asStatement());
      }
      condition = builder.build();
    } else {
      condition =
          Statement.ifStatement(
                  selectedMsg.doubleEquals(fallbackCodeGenInfo.googMsgVar),
                  selectedMsg.assign(getMessageFormatCall(fallbackCodeGenInfo)).asStatement())
              .build();
    }
    return Expression.id(tmpVarName).withInitialStatement(condition);
  }
660039
function MsgStream(cfg) {
	assert(cfg, 'Cannot set up a message stream without configuration');
	assert(cfg.transports, 'Cannot set up a message stream without transports configured');

	EventEmitter.call(this);

	this.cfg = cfg;
	this.addressMap = {};
	this.closing = false;
}
1131400
function dispatchEvent(normalizedEvents) {
       var handled = false;

       while (normalizedEvents.length > 0) {
         // keep a reference to the last item
         var pointer = normalizedEvents.pop(); // and put it back into our cache

         T_POINTERS.push(pointer); // Do not fire older events

         if (typeof pointer.event.timeStamp !== "undefined") {
           if (pointer.event.timeStamp < lastTimeStamp) {
             continue;
           }

           lastTimeStamp = pointer.event.timeStamp;
         }

         currentPointer.setShape(pointer.gameWorldX, pointer.gameWorldY, pointer.width, pointer.height); // trigger a global event for pointer move

         if (POINTER_MOVE.includes(pointer.type)) {
           pointer.gameX = pointer.gameLocalX = pointer.gameScreenX;
           pointer.gameY = pointer.gameLocalY = pointer.gameScreenY;
           me.event.publish(me.event.POINTERMOVE, [pointer]);
         }

         var candidates = me.collision.quadTree.retrieve(currentPointer, me.Container.prototype._sortReverseZ); // add the main viewport to the list of candidates

         candidates = candidates.concat([me.game.viewport]);

         for (var c = candidates.length, candidate; c--, candidate = candidates[c];) {
           if (eventHandlers.has(candidate) && candidate.isKinematic !== true) {
             var handlers = eventHandlers.get(candidate);
             var region = handlers.region;
             var ancestor = region.ancestor;
             var bounds = region.getBounds();
             var eventInBounds = false;

             if (region.floating === true) {
               pointer.gameX = pointer.gameLocalX = pointer.gameScreenX;
               pointer.gameY = pointer.gameLocalY = pointer.gameScreenY;
             } else {
               pointer.gameX = pointer.gameLocalX = pointer.gameWorldX;
               pointer.gameY = pointer.gameLocalY = pointer.gameWorldY;
             } // adjust gameLocalX to specify coordinates
             // within the region ancestor container


             if (typeof ancestor !== "undefined") {
               var parentPos = ancestor.getBounds().pos;
               pointer.gameLocalX = pointer.gameX - parentPos.x;
               pointer.gameLocalY = pointer.gameY - parentPos.y;
             }

             if (region instanceof me.Sprite) {
               var gameX = pointer.gameX;
               var gameY = pointer.gameY;

               if (!region.currentTransform.isIdentity()) {
                 var invV = region.currentTransform.multiplyVectorInverse(me.pool.pull("me.Vector2d", gameX, gameY));
                 gameX = invV.x;
                 gameY = invV.y;
                 me.pool.push(invV);
               }

               eventInBounds = bounds.containsPoint(gameX, gameY);
             } else {
               eventInBounds = bounds.containsPoint(pointer.gameX, pointer.gameY) && (bounds === region || // if the given target is another shape than me.Rect
               region.containsPoint(pointer.gameLocalX, pointer.gameLocalY));
             }

             switch (pointer.type) {
               case POINTER_MOVE[0]:
               case POINTER_MOVE[1]:
               case POINTER_MOVE[2]:
               case POINTER_MOVE[3]:
                 // moved out of bounds: trigger the POINTER_LEAVE callbacks
                 if (handlers.pointerId === pointer.pointerId && !eventInBounds) {
                   if (triggerEvent(handlers, findActiveEvent(activeEventList, POINTER_LEAVE), pointer, null)) {
                     handled = true;
                     break;
                   }
                 } // no pointer & moved inside of bounds: trigger the POINTER_ENTER callbacks
                 else if (handlers.pointerId === null && eventInBounds) {
                     if (triggerEvent(handlers, findActiveEvent(activeEventList, POINTER_ENTER), pointer, pointer.pointerId)) {
                       handled = true;
                       break;
                     }
                   } // trigger the POINTER_MOVE callbacks


                 if (eventInBounds && triggerEvent(handlers, pointer.type, pointer, pointer.pointerId)) {
                   handled = true;
                   break;
                 }

                 break;

               case POINTER_UP[0]:
               case POINTER_UP[1]:
               case POINTER_UP[2]:
               case POINTER_UP[3]:
                 // pointer defined & inside of bounds: trigger the POINTER_UP callback
                 if (handlers.pointerId === pointer.pointerId && eventInBounds) {
                   // trigger the corresponding callback
                   if (triggerEvent(handlers, pointer.type, pointer, null)) {
                     handled = true;
                     break;
                   }
                 }

                 break;

               case POINTER_CANCEL[0]:
               case POINTER_CANCEL[1]:
               case POINTER_CANCEL[2]:
               case POINTER_CANCEL[3]:
                 // pointer defined: trigger the POINTER_CANCEL callback
                 if (handlers.pointerId === pointer.pointerId) {
                   // trigger the corresponding callback
                   if (triggerEvent(handlers, pointer.type, pointer, null)) {
                     handled = true;
                     break;
                   }
                 }

                 break;

               default:
                 // event inside of bounds: trigger the POINTER_DOWN or WHEEL callback
                 if (eventInBounds) {
                   // trigger the corresponding callback
                   if (triggerEvent(handlers, pointer.type, pointer, pointer.pointerId)) {
                     handled = true;

                     if (pointer.type === "wheel") {
                       api._preventDefaultFn(pointer.event);
                     }

                     break;
                   }
                 }

                 break;
             }
           }

           if (handled === true) {
             // stop iterating through this list of candidates
             break;
           }
         }
       }

       return handled;
     }
1190151
function(msg) {
      var gameOverElement = document.getElementById('gameOver'),
          gameOverMsgElement = document.getElementById('gameOverMsg'),
          waitingForPlayerElem = document.getElementById('waitingForPlayer');
      if (msg === false)  {
        gameOverElement.style.display = 'none';
      }
      else {
        gameOverMsgElement.innerText = msg;
        gameOverElement.style.display = 'block';
        waitingForPlayerElem.style.display = 'none';
      }
    }
528502
function createSagas(saga_list) {
  var arr = [];
  var GeneratorFunction = Object.getPrototypeOf( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
    return regeneratorRuntime.wrap(function _callee$(_context) {
      while (1) {
        switch (_context.prev = _context.next) {
          case 0:
          case "end":
            return _context.stop();
        }
      }
    }, _callee, this);
  })).constructor;
  var saga_keys = Object.keys(saga_list);
  saga_keys.forEach(function (key) {
    var action = key.split(".")[0];
    var worker_saga = saga_list[key];
    var mode = key.split(".")[1] || "latest";
    var watcher = null;
    if (mode == "latest") {
      watcher = /*#__PURE__*/regeneratorRuntime.mark(function watcher() {
        return regeneratorRuntime.wrap(function watcher$(_context2) {
          while (1) {
            switch (_context2.prev = _context2.next) {
              case 0:
                _context2.next = 2;
                return (0, _effects.takeLatest)(action, worker_saga);

              case 2:
              case "end":
                return _context2.stop();
            }
          }
        }, watcher, this);
      });
    } else if (mode == "every") {
      watcher = /*#__PURE__*/regeneratorRuntime.mark(function watcher() {
        return regeneratorRuntime.wrap(function watcher$(_context3) {
          while (1) {
            switch (_context3.prev = _context3.next) {
              case 0:
                _context3.next = 2;
                return (0, _effects.takeEvery)(action, worker_saga);

              case 2:
              case "end":
                return _context3.stop();
            }
          }
        }, watcher, this);
      });
    }
    arr.push(watcher());
  });
  return arr;
}
488400
function generator(seed) {
    // Note: the generator didn't work with negative seed values, so here we
    // transform our original seed into a new (positive) seed value with which we
    // create a new generator.
    if (seed < 0) {
        var gen = generator(Math.abs(seed));
        for (var i = 0; i < 23; i += 1) {
            gen();
        }
        return generator(gen(0, 10000));
    }

    // Based on random number generator from
    // http://indiegamr.com/generate-repeatable-random-numbers-in-js/
    return function (min, max) {
        min = min || 0;
        max = max || 1;
        seed = (seed * 9301 + 49297) % 233280;
        var v = seed / 233280;
        return min + v * (max - min);
    };
}
1136172
function GameMsg(gm) {
        gm = gm || {};

        /**
         * ### GameMsg.id
         *
         * A randomly generated unique id
         */
        this.id = 'undefined' === typeof gm.id ?
            Math.floor(Math.random()*1000000) : gm.id;

        /**
         * ### GameMsg.sid
         *
         * The socket id, if provided
         *
         * Used by SocketIO to prevent spoofing, not used by other sockets
         * TODO: could this be session instead?
         */
        this.sid = gm.sid;

        /**
         * ### GameMsg.session
         *
         * The session id in which the message was generated
         */
        this.session = gm.session;

        /**
         * ### GameMsg.stage
         *
         * The game-stage in which the message was generated
         *
         * @see GameStage
         */
        this.stage = gm.stage;

        /**
         * ### GameMsg.action
         *
         * The action of the message
         *
         * @see node.constants.action
         */
        this.action = gm.action;

        /**
         * ### GameMsg.target
         *
         * The target of the message
         *
         * @see node.constants.target
         */
        this.target = gm.target;

        /**
         * ### GameMsg.from
         *
         * The id of the sender of the message
         *
         * @see Player.id
         * @see node.player.id
         */
        this.from = gm.from;

        /**
         * ### GameMsg.to
         *
         * The id of the receiver of the message
         *
         * @see Player.id
         * @see node.player.id
         */
        this.to = gm.to;

        /**
         * ### GameMsg.text
         *
         * An optional text adding a description for the message
         */
        this.text = gm.text;

        /**
         * ### GameMsg.data
         *
         * An optional payload field for the message
         */
        this.data = gm.data;

        /**
         * ### GameMsg.priority
         *
         * A priority index associated to the message
         */
        this.priority = gm.priority;

        /**
         * ### GameMsg.reliable
         *
         * Experimental. Disabled for the moment
         *
         * If set, requires ackwnoledgment of delivery
         */
        this.reliable = gm.reliable;

        /**
         * ### GameMsg.created
         *
         * A timestamp of the date of creation
         */
        this.created = J.getDate();

        /**
         * ### GameMsg.forward
         *
         * If TRUE, the message is a forward.
         *
         * E.g. between nodeGame servers
         */
        this.forward = 0;
    }
37465
function FileManager(generator, config, logger) {
        this._generator = generator;
        this._config = config;
        this._logger = logger;

        this._queue = new AsyncQueue();
        this._queue.pause();
        this._queue.on("error", function (err) {
            this._logger.error(err);
        }.bind(this));
    }
1192421
function Game(node) {

        this.node = node;

        // This updates are never published.
        this.setStateLevel(constants.stateLevels.UNINITIALIZED, 'S');
        this.setStageLevel(constants.stageLevels.UNINITIALIZED, 'S');

        // ## Properties

        /**
         * ### Game.metadata
         *
         * The game's metadata
         *
         * This object is normally filled-in automatically with data
         * from the file `package.json` inside the game folder.
         *
         * Contains at least the following properties:
         *
         *  - name,
         *  - description,
         *  - version
         */
        this.metadata = {
            name:        'A nodeGame game',
            description: 'No description',
            version:     '0.0.1'
        };

        /**
         * ### Game.settings
         *
         * The game's settings
         *
         * This object is normally filled-in automatically with the settings
         * contained in the game folder: `game/game.settings`,
         * depending also on the chosen treatment.
         */
        this.settings = {};

        /**
         * ### Game.pl | playerList
         *
         * The list of players connected to the game
         *
         * The list may be empty, depending on the server settings.
         *
         * Two players with the same id, or any player with id equal to
         * `node.player.id` is not allowed, and it will throw an error.
         */
        this.playerList = this.pl = new PlayerList({
            log: this.node.log,
            logCtx: this.node,
            name: 'pl_' + this.node.nodename
        });

        this.pl.on('insert', function(p) {
            if (p.id === node.player.id) {
                throw new Error('node.game.pl.on.insert: cannot add player ' +
                                'with id equal to node.player.id.');
            }
        });

        /**
         * ### Game.ml | monitorList
         *
         * The list of monitor clients connected to the game
         *
         * The list may be empty, depending on the server settings
         */
        this.monitorList = this.ml = new PlayerList({
            log: this.node.log,
            logCtx: this.node,
            name: 'ml_' + this.node.nodename
        });

        /**
         * ### Game.memory
         *
         * A storage database for the game
         *
         * In the server logic the content of SET messages are
         * automatically inserted in this object
         *
         * @see NodeGameClient.set
         */
        this.memory = new GameDB({
            log: this.node.log,
            logCtx: this.node,
            shared: { node: this.node }
        });

        /**
         * ### Game.plot
         *
         * The Game plot
         *
         * @see GamePlot
         */
        this.plot = new GamePlot(this.node, new Stager());

// TODO: check if we need this.
//        // Overriding stdout for game plot and stager.
//        this.plot.setDefaultLog(function() {
//            // Must use apply, else will be executed in the wrong context.
//            node.log.apply(node, arguments);
//        });

        /**
         * ### Game.role
         *
         * The "role" currently held in this game (if any)
         *
         * @see Game.gotoStep
         * @see Game.setRole
         * @see processGotoStepOptions
         */
        this.role = null;

        /**
         * ### Game.partner
         *
         * The id or alias of the "partner" in this game (if any)
         *
         * Some games are played in pairs, this variable holds the id
         * of the partner player.
         *
         * @see Game.setPartner
         * @see processGotoStepOptions
         */
        this.partner = null;

        /**
         * ### Game.matcher
         *
         * Handles assigning matching tasks
         *
         * Assigns roles to players, players to players, etc.
         *
         * @see Game.gotoStep
         */
        this.matcher = MatcherManager ? new MatcherManager(this.node) : null;

        /**
         * ### Game.timer
         *
         * Default game timer synced with stager 'timer' property
         *
         * @see GameTimer
         * @see GameTimer.syncWithStager
         */
        this.timer = this.node.timer.createTimer({
            name: 'game_timer',
            stagerSync: true
        });



        // Setting to stage 0.0.0 and starting.
        this.setCurrentGameStage(new GameStage(), 'S');
        this.setStateLevel(constants.stateLevels.STARTING, 'S');

        /**
         * ### Game.paused
         *
         * TRUE, if the game is paused
         *
         * @see Game.pause
         * @see Game.resume
         */
        this.paused = false;

        /**
         * ### Game.pauseCounter
         *
         * Counts the number of times the game was paused
         *
         * @see Game.pause
         * @see Game.resume
         */
        this.pauseCounter = 0;

        /**
         * ### Game.willBeDone
         *
         * TRUE, if DONE was emitted and evaluated successfully
         *
         * If TRUE, when PLAYING is emitted `node.done` is called
         * immediately, and the game tries to step forward.
         *
         * @see NodeGameClient.done
         */
        this.willBeDone = false;

        /**
         * ### Game.globals
         *
         * Object pointing to the current step _globals_ properties
         *
         * Whenever a new step is executed the _globals_ properties of
         * the step are copied here. The _globals_ properties of the previous
         * stage are deleted.
         *
         * @see GamePlot
         * @see Stager
         */
        this.globals = {};

        /**
         * ### Game._steppedSteps
         *
         * Array of steps previously played
         *
         * @see Game.step
         */
        this._steppedSteps = [ new GameStage() ];

        /**
         * ### Game._breakStage
         *
         * Flags to break current stage at next node.done call
         *
         * @see Game.breakStage
         */
        this._breakStage = false;

        /** ### Game.pushManager
         *
         * Handles pushing client to advance to next step
         *
         * @see PushManager
         */
        this.pushManager = new PushManager(this.node);

        /** ### Game.sizeManager
         *
         * Handles changes in the number of connected players
         *
         * @see SizeManager
         */
        this.sizeManager = new SizeManager(this.node);
    }
736604
def generated_gamemakerstudio?
      return false unless ['.yy', '.yyp'].include? extname
      return false unless lines.count > 3
      return lines[2].match(/\"modelName\"\:\s*\"GM/) ||
             lines[0] =~ /^\d\.\d\.\d.+\|\{/
    end
427415
function init(player) {  // {{{2
/**
 * @method constructor
 */

  this.timeout = 10 * 1000;

  this.target = player;

  this.actions = {
    mute: {
      command: 'mute',
      data: 'toggle',
      firstOnly: true,
    },
    stop: {
      command: 'stop',
      data: true,
      firstOnly: true,
    },
    pause: {
      command: 'pause',
      data: true,
      firstOnly: true,
    },
    play: {
      command: 'play',
      data: true,
      firstOnly: true,
    },
    playpause: {
      command: 'playPause',
      data: true,
      firstOnly: true,
    },
    forward: {
      command: 'next',
      data: true,
    },
    back: {
      command: 'previous',
      data: true,
    },
    volumeup: {
      command: 'volume',
      data: 'up'
    },
    volumedown: {
      command: 'volume',
      data: 'down'
    },
  };

  this.actions.rewind = this.actions.back;
}
47669
public static void main(String[] args) throws Exception {
    Builder processingGraphBuilder = Builder.newBuilder();

    /**
     * A supplier streamlet of random GameScore objects is cloned into two
     * separate streamlets.
     */
    List<Streamlet<GameScore>> splitGameScoreStreamlet = processingGraphBuilder
        .newSource(GameScore::new)
        .clone(2);

    /**
     * Elements in the first cloned streamlet go to the database sink.
     */
    splitGameScoreStreamlet.get(0)
        .toSink(new DatabaseSink());

    /**
     * Elements in the second cloned streamlet go to the logging sink.
     */
    splitGameScoreStreamlet.get(1)
        .toSink(new FormattedLogSink());

    Config config = Config.defaultConfig();

    // Fetches the topology name from the first command-line argument
    String topologyName = StreamletUtils.getTopologyName(args);

    // Finally, the processing graph and configuration are passed to the Runner, which converts
    // the graph into a Heron topology that can be run in a Heron cluster.
    new Runner().run(topologyName, config, processingGraphBuilder);
  }
658023
function handleGame(request, response, game, path) {
    var resp;
    switch(path[0]) {
    case 'board':
        // add pieces to the board
        if (request.method === "POST") {
            requestBody(request, function(form) {

                var player = playerFromReq(request, response, game);
                // console.info('adding pieces, player:'+player.name);
                // console.info('form info:'+JSON.stringify(form));

                if (form && form.shape && form.color &&
                    form.row && form.column && player) {

                    // TODO should do form check?
                    var row = parseInt(form.row, 10);
                    var column = parseInt(form.column, 10);
                    var piece = new Piece(form.shape, form.color);

                    // check player has piece
                    var idx = -1, _idx = 0;
                    for (var p in player.pieces) {
                        var _piece = player.pieces[p];
                        //console.log('check:'+JSON.stringify(p)+', and:'+
                        //          JSON.stringify(piece));
                        if (piece.equals(_piece)) {
                            idx = _idx;
                            break;
                        }
                        _idx += 1;
                    }

                    if (idx > -1) {
                        var gp = new GamePiece(piece, row, column);
                        // console.info('adding piece:'+JSON.stringify(gp));
                        resp = addGamePiece(game, gp);
                        if (typeof resp === "string") {
                            // add gamepiece failed
                            response.writeHead(409, {'Content-Type': 'text/json'});
                            response.write(resp, 'utf-8');
                            response.end();
                            return;
                        } else {
                            // add gamepiece succeeded
                            player.points += resp;
                            player.pieces.splice(idx, 1);
                            respOk(response, '', 'text/json');
                        }
                    }
                }
            });
            return;
        }
        // get pieces on the board
        resp = JSON.stringify(game.board);
        break;
    case 'players':
        handlePlayers(request, response, game, path.slice(1));
        return;
    case 'pieces':
        // get pieces in the bag
        resp = JSON.stringify(game.pieces);
        break;
    case 'chat':
        handleChat(request, response, game.chat);
        break;
    case 'dimensions':
        resp = JSON.stringify(game.dimensions);
    }
    respOk(response, resp, 'text/json');
}
812706
function(id, gameGroup, options) {
  options = options || {};
  this.id = id;
  this.gameGroup = gameGroup;
  this.players = {};
  this.numPlayers = 0;
  this.sendQueue = [];
  this.options = options;
  this.setGameId();
  debug("create game " + this.gameId);
}
448768
function MQTTMsgBusDebugInNode(config) {
        RED.nodes.createNode(this, config)

        this.qos = 0
        this.source = config.source
        
        if (typeof this.source === 'undefined'){
            this.source = "+"
        } else if (this.source == "") {
            this.source = "+"
        }

        this.client     = config.client
        this.clientConn = RED.nodes.getNode(this.client)

        this.broker     = this.clientConn.broker
        this.brokerConn = RED.nodes.getNode(this.broker)

        var node = this

        if (this.brokerConn) {
            this.status({fill:"red", shape:"ring", text:"node-red:common.status.disconnected"})

            this.topic = topicDebugSubscribe(this.clientConn, this.source)

            node.brokerConn.register(this)

            this.brokerConn.subscribe(this.topic, this.qos, function(topic, payload, packet) {
                onDebugHandler(node, node.brokerConn, topic, payload)
            }, this.id)

            if (this.brokerConn.connected) {
                node.status({fill:"green", shape:"dot", text:"node-red:common.status.connected"})
            }

            this.on('close', function(done) {
                if (node.brokerConn) {
                    node.brokerConn.unsubscribe(node.topic, node.id)
                    node.brokerConn.deregister(node, done)
                }
            })
        } else {
            this.error(RED._("msgbus.errors.missing-config"))
        }

    }