Package org.menacheri.jetserver.app

Examples of org.menacheri.jetserver.app.GameRoom


  }
 
  public static void startGames(AbstractApplicationContext ctx)
  {
    World world = ctx.getBean(World.class);
    GameRoom room1 = (GameRoom)ctx.getBean("Zombie_ROOM_1");
    GameRoom room2 = (GameRoom)ctx.getBean("Zombie_ROOM_2");
    Task monitor1 = new WorldMonitor(world,room1);
    Task monitor2 = new WorldMonitor(world,room2);
    TaskManagerService taskManager = ctx.getBean(TaskManagerService.class);
    taskManager.scheduleWithFixedDelay(monitor1, 1000, 5000, TimeUnit.MILLISECONDS);
    taskManager.scheduleWithFixedDelay(monitor2, 2000, 5000, TimeUnit.MILLISECONDS);
View Full Code Here


        .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);
    playerSession.addHandler(new SessionHandlerLatchCounter(playerSession,
        counter, latch));
    playerSession.onEvent(event);
    assertTrue(latch.await(500, TimeUnit.MILLISECONDS));
  }
View Full Code Here

    CountDownLatch latch1 = new CountDownLatch(2);
    CountDownLatch latch2 = new CountDownLatch(2);
    AtomicLong counter = new AtomicLong(0l);
    Session gameRoomSession = new TestGameRoom(sessionBuilder, counter,
        latch1);
    GameRoom gameRoom = (GameRoom) gameRoomSession;
    PlayerSession playerSession = gameRoom.createPlayerSession(null);
    PlayerSession playerSession2 = gameRoom.createPlayerSession(null);
    PlayerSession playerSession3 = gameRoom.createPlayerSession(null);
    gameRoom.connectSession(playerSession);
    gameRoom.connectSession(playerSession2);
    gameRoom.connectSession(playerSession3);
    playerSession.addHandler(new SessionHandlerLatchCounter(playerSession,
        counter, latch1));
    playerSession2.addHandler(new SessionHandlerLatchCounter(playerSession,
        counter, latch2));
    playerSession3.addHandler(new SessionHandlerLatchCounter(playerSession,
View Full Code Here

  {
    if (null != playerSession)
    {
      channel.write(NettyUtils
          .createBufferForOpcode(Events.LOG_IN_SUCCESS));
      GameRoom gameRoom = playerSession.getGameRoom();
      gameRoom.disconnectSession(playerSession);
      if (null != playerSession.getTcpSender())
        playerSession.getTcpSender().close();

      if (null != playerSession.getUdpSender())
        playerSession.getUdpSender().close();
View Full Code Here

 
  public void handleGameRoomJoin(Player player, Channel channel, ChannelBuffer buffer)
  {
    String refKey = NettyUtils.readString(buffer);
   
    GameRoom gameRoom = lookupService.gameRoomLookup(refKey);
    if(null != gameRoom)
    {
      PlayerSession playerSession = gameRoom.createPlayerSession(player);
      gameRoom.onLogin(playerSession);
      String reconnectKey = (String)idGeneratorService
          .generateFor(playerSession.getClass());
      playerSession.setAttribute(JetConfig.RECONNECT_KEY, reconnectKey);
      playerSession.setAttribute(JetConfig.RECONNECT_REGISTRY, reconnectRegistry);
      LOG.trace("Sending GAME_ROOM_JOIN_SUCCESS to channel {}", channel.getId());
View Full Code Here

  protected void handleReconnect(PlayerSession playerSession, Channel channel)
  {
    if (null != playerSession)
    {
      channel.write(eventToFrame(Events.LOG_IN_SUCCESS, null));
      GameRoom gameRoom = playerSession.getGameRoom();
      gameRoom.disconnectSession(playerSession);
      if (null != playerSession.getTcpSender())
        playerSession.getTcpSender().close();

      handleReJoin(playerSession, gameRoom, channel);
    }
View Full Code Here

        ChannelFutureListener.CLOSE);
  }

  public void handleGameRoomJoin(Player player, Channel channel, String refKey)
  {
    GameRoom gameRoom = lookupService.gameRoomLookup(refKey);
    if (null != gameRoom)
    {
      PlayerSession playerSession = gameRoom.createPlayerSession(player);
      gameRoom.onLogin(playerSession);
      String reconnectKey = (String)idGeneratorService
          .generateFor(playerSession.getClass());
      playerSession.setAttribute(JetConfig.RECONNECT_KEY, reconnectKey);
      playerSession.setAttribute(JetConfig.RECONNECT_REGISTRY, reconnectRegistry);
      LOG.trace("Sending GAME_ROOM_JOIN_SUCCESS to channel {}",
View Full Code Here

TOP

Related Classes of org.menacheri.jetserver.app.GameRoom

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.