Package org.menacheri.jetserver.app.impl.GameRoomSession

Examples of org.menacheri.jetserver.app.impl.GameRoomSession.GameRoomSessionBuilder


  @Test
  public void sessionDisconnectValidation() throws InterruptedException {
    // create necessary setup objects.
    Game game = new SimpleGame(1, "Test");
    Protocol dummyProtocol = new DummyProtocol();
    GameRoomSessionBuilder sessionBuilder = new GameRoomSessionBuilder();
    sessionBuilder.parentGame(game).gameRoomName("Zombie_ROOM_1")
        .protocol(dummyProtocol);
    CountDownLatch latch = new CountDownLatch(1);
    AtomicLong counter = new AtomicLong(1l);
    Session gameRoomSession = new TestGameRoom(sessionBuilder, counter,
        latch);
    GameRoom gameRoom = (GameRoom) gameRoomSession;
    PlayerSession playerSession = gameRoom.createPlayerSession(null);
    gameRoom.connectSession(playerSession);
    playerSession.addHandler(new SessionHandlerLatchCounter(playerSession,
        counter, latch));

    // start test
    gameRoom.disconnectSession(playerSession);
    JetlangEventDispatcher gameDispatcher = (JetlangEventDispatcher) gameRoomSession
        .getEventDispatcher();
    assertNoListeners(gameDispatcher);
    Event event = Events.event(null, Events.SESSION_MESSAGE);
    playerSession.onEvent(event);
    assertFalse(latch.await(500, TimeUnit.MILLISECONDS));

    // Connect to another game room
    sessionBuilder.gameRoomName("Zombie_ROOM_2");

    Session gameRoomSession2 = new TestGameRoom(sessionBuilder, counter,
        latch);
    GameRoom gameRoom2 = (GameRoom) gameRoomSession2;
    gameRoom2.connectSession(playerSession);
View Full Code Here


  @Test
  public void multiSessionDisconnectValidation() throws InterruptedException {
    // create necessary setup objects.
    Game game = new SimpleGame(1, "Test");
    Protocol dummyProtocol = new DummyProtocol();
    GameRoomSessionBuilder sessionBuilder = new GameRoomSessionBuilder();
    sessionBuilder.parentGame(game).gameRoomName("Zombie_ROOM_1")
        .protocol(dummyProtocol);
    CountDownLatch latch1 = new CountDownLatch(2);
    CountDownLatch latch2 = new CountDownLatch(2);
    AtomicLong counter = new AtomicLong(0l);
    Session gameRoomSession = new TestGameRoom(sessionBuilder, counter,
View Full Code Here

    gameRoomList = new ArrayList<GameRoom>(NUM_OF_GAME_ROOMS);
    sessionList = new ArrayList<Session>(NUM_OF_GAME_ROOMS
        * SESSIONS_PER_GAME_ROOM);
    for (int i = 1; i <= NUM_OF_GAME_ROOMS; i++)
    {
      GameRoomSessionBuilder sessionBuilder = new GameRoomSessionBuilder();
      sessionBuilder.parentGame(game).gameRoomName("Zombie_ROOM_" + i)
          .protocol(DUMMY_PROTOCOL);
      Session gameRoomSession = new TestGameRoom(sessionBuilder);
      gameRoomSession.addHandler(new GameRoomSessionHandler(
          gameRoomSession));
      gameRoomList.add((GameRoom) gameRoomSession);
View Full Code Here

    gameRoomList = new ArrayList<GameRoom>(NUM_OF_GAME_ROOMS);
    sessionList = new ArrayList<Session>(NUM_OF_GAME_ROOMS
        * SESSIONS_PER_GAME_ROOM);
    for (int i = 1; i <= NUM_OF_GAME_ROOMS; i++)
    {
      GameRoomSessionBuilder sessionBuilder = new GameRoomSessionBuilder();
      sessionBuilder.parentGame(game).gameRoomName("Zombie_ROOM_" + i)
          .protocol(DUMMY_PROTOCOL).eventDispatcher(new ExecutorEventDispatcher());
      Session gameRoomSession = new TestGameRoom(sessionBuilder);
      gameRoomSession.addHandler(new GameRoomSessionHandler(
          gameRoomSession));
      gameRoomList.add((GameRoom) gameRoomSession);
View Full Code Here

    return game;
  }
 
  public @Bean(name="Zombie_ROOM_1") GameRoom zombieRoom1()
  {
    GameRoomSessionBuilder sessionBuilder = new GameRoomSessionBuilder();
    sessionBuilder.parentGame(zombieGame()).gameRoomName("Zombie_ROOM_1").protocol(messageBufferProtocol);
    ZombieRoom room = new ZombieRoom(sessionBuilder);
    room.setDefender(defender());
    room.setZombie(zombie());
   
    return room;
View Full Code Here

    return room;
  }
 
  public @Bean(name="Zombie_ROOM_2") GameRoom zombieRoom2()
  {
    GameRoomSessionBuilder sessionBuilder = new GameRoomSessionBuilder();
    sessionBuilder.parentGame(zombieGame()).gameRoomName("Zombie_ROOM_2").protocol(webSocketProtocol);
    ZombieRoom room = new ZombieRoom(sessionBuilder);
    room.setDefender(defender());
    room.setZombie(zombie());
   
    return room;
View Full Code Here

TOP

Related Classes of org.menacheri.jetserver.app.impl.GameRoomSession.GameRoomSessionBuilder

Copyright © 2018 www.massapicom. 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.