Examples of GameHandler


Examples of com.github.xgameenginee.handler.GameHandler

            }
            GameUpBuffer c = null;
            while ((c = msgQueue.poll()) != null) {
                short type = c.getShort();
                try {
                    GameHandler handler = GameHandlerManager.getInstance().getHandler(type);
                    if (handler != null) {
                        if (!handler.isSystem() && c.attachment() == null) // real upstream message
                            handler.process(c.getConnection(), c);
                        else if (handler.isSystem()) // the system message
                            handler.process(c.getConnection(), c);
                        else {
                            logger.error("error in upstream :" + type);
                        }
                    } else {
                        logger.error("error type = " + type);
View Full Code Here

Examples of com.l2client.network.game.GameHandler

      log.fine("Creating connection to GameServer on host "+host+":"+port);
      this.loginKey1 = login1;
      this.loginKey2 = login2;
      this.playKey1 = play1;
      this.playKey2 = play2;
        gameSocket = new GameHandler(host,port);
        gameSocket.clientFacade = this;
    }
View Full Code Here

Examples of com.music.web.websocket.GameHandler

        return session;
    }

    @Test
    public void gameInitializedTest() throws Exception {
        GameHandler handler = new GameHandler();
        initializeGame(handler);

        GameEvent response = mapper.readValue(messages.get("1").removeLast().getPayload().toString(), GameEvent.class);
        Assert.assertEquals(GameEventType.GAME_INITIALIZED, response.getType());

        Assert.assertEquals(1, handler.getGames().size());

        Game game = handler.getGames().values().iterator().next();
        Assert.assertEquals(game.getId(), response.getGameId());
    }
View Full Code Here

Examples of com.music.web.websocket.GameHandler

    }

    @Test
    public void gameStartedTest() throws Exception {

        GameHandler handler = new GameHandler();
        handler.setPieceService(pieceServiceMock);

        initializeGame(handler);
        Game game = handler.getGames().values().iterator().next();

        GameMessage startMsg = new GameMessage();
        startMsg.setAction(GameAction.START);
        startMsg.setGameId(game.getId());

        WebSocketSession session = getSession("1");
        handler.handleMessage(session, getTextMessage(startMsg));

        GameEvent responseNewPiece = mapper.readValue(messages.get("1").removeLast().getPayload().toString(), GameEvent.class);
        GameEvent responseGameStarted = mapper.readValue(messages.get("1").removeLast().getPayload().toString(), GameEvent.class);
        Assert.assertEquals(GameEventType.GAME_STARTED, responseGameStarted.getType());
View Full Code Here

Examples of com.music.web.websocket.GameHandler

    }

    @Test
    public void playerJoinedTest() throws Exception {

        GameHandler handler = new GameHandler();
        handler.setPieceService(pieceServiceMock);

        initializeGame(handler);
        Game game = handler.getGames().values().iterator().next();

        GameMessage playerJoinMsg = new GameMessage();
        playerJoinMsg.setAction(GameAction.JOIN);
        playerJoinMsg.setPlayerName("AAA");
        playerJoinMsg.setGameId(game.getId());

        getSession("1");
        WebSocketSession player2Session = getSession("2");

        handler.afterConnectionEstablished(player2Session);

        handler.handleMessage(player2Session, getTextMessage(playerJoinMsg));

        GameEvent playerJoinedEvent = mapper.readValue(messages.get("1").removeLast().getPayload().toString(), GameEvent.class);
        Assert.assertEquals(GameEventType.PLAYER_JOINED, playerJoinedEvent.getType());
        Assert.assertEquals(playerJoinedEvent.getPlayerId(), "2");
View Full Code Here

Examples of com.music.web.websocket.GameHandler

    }

    @Test
    public void gameFinishedTest() throws Exception {
        GameHandler handler = new GameHandler();
        handler.setPieceService(pieceServiceMock);

        initializeGame(handler);
        Game game = handler.getGames().values().iterator().next();


        GameMessage playerJoinMsg = new GameMessage();
        playerJoinMsg.setAction(GameAction.JOIN);
        playerJoinMsg.setPlayerName("AAA");
        playerJoinMsg.setGameId(game.getId());
        WebSocketSession session = getSession("1");

        handler.handleMessage(session, getTextMessage(playerJoinMsg));
        game.setSecondsBeforeNextPiece(0);

        // Answer all three questions
        for (int i = 0; i < 3; i ++) {
            game.sendNextPiece();
            GameMessage answerMsg = new GameMessage();
            answerMsg.setAction(GameAction.ANSWER);
            com.music.web.websocket.dto.Answer answer = new com.music.web.websocket.dto.Answer();
            answer.setMainInstrument(0);
            answer.setMetreNumerator(2);
            answer.setMetreDenominator(4);
            answer.setTempo(80);
            answerMsg.setAnswer(answer);
            answerMsg.setGameId(game.getId());
            handler.handleMessage(session, getTextMessage(answerMsg));
        }
        Assert.assertFalse(game.isStarted());
        Assert.assertTrue(game.getResults().getRanking().contains("1"));
        Assert.assertTrue(game.getResults().getScores().containsKey(playerJoinMsg.getPlayerName()));
    }
View Full Code Here

Examples of de.beimax.simplespleef.game.GameHandler

   
    // check updates, if turned on
    checkForUpdate();
   
    // create new handler
    SimpleSpleef.gameHandler = new GameHandler();
    SimpleSpleef.gameHandler.updateGameHandlerData();
    // start tracking
    SimpleSpleef.getPlugin().getServer().getScheduler().scheduleSyncRepeatingTask(this, gameHandler, 0L, 20L);
   
    // register vault stuff
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.