java-client-listener

*We assure you that we do not spam. You may receive occasional emails from us.
 You can always unsubscribe.
Java

Java Client Listeners

ConnectionRequestListener
  
   /** 
   * Invoked in response to a connect request. 
   * @param event 
   */ 
  @Override
    public void onConnectDone(ConnectEvent event,String str) {
     String message="";
       switch(event.getResult())
       {
           case WarpResponseResultCode.AUTH_ERROR:
               message="Auth Error";
               break;
           case WarpResponseResultCode.BAD_REQUEST:
                message="Bad Request";
               break;
           case WarpResponseResultCode.CONNECTION_ERROR:
                message="Connection Error";
               break;
           case WarpResponseResultCode.CONNECTION_ERROR_RECOVERABLE:
                message="Connection Error Recoverable";
                break;
           case WarpResponseResultCode.SUCCESS:
                message="Connection Success";
                break;
           case WarpResponseResultCode.SUCCESS_RECOVERED:
                message="Success Recovered";
                break;
           default:break;
       }
         System.out.println("onConnectDone "+message);  
    }

  /** 
   * Invoked in response to a disconnect request. 
   * @param event 
   */
  @Override
    public void onDisconnectDone(ConnectEvent event) {
        System.out.println("onDisconnectDone "+event.getResult());  
    }

  /**
   * Invoked in response to a init UDP request.
   * @param result
   */
     @Override
    public void onInitUDPDone(byte result)
    {
       System.out.println("onInitUDPDone  :result " + result);  
    }
RoomRequestListener
  
   /** 
   * Invoked in response to a subscribeRoom request. 
   * @param event 
   */
@Override
    public void onSubscribeRoomDone(RoomEvent event) {
        System.out.println("onSubscribeRoomDone :" + event.getResult());
        if (event.getResult() == WarpResponseResultCode.SUCCESS) {
            System.out.println("room Id :" + event.getData().getId());
            System.out.println("Room name :" + event.getData().getName());
            System.out.println("Room Owner : " + event.getData().getRoomOwner());
            System.out.println("Max Users : " + event.getData().getMaxUsers());
        }
    }

  /** 
   * Invoked in response to a UnSubscribeRoom request. 
   * @param event 
   */
@Override
   public void onUnSubscribeRoomDone(RoomEvent event) {
        System.out.println("onUnSubscribeRoomDone :" + event.getResult());
        if (event.getResult() == WarpResponseResultCode.SUCCESS) {
            System.out.println("room Id :" + event.getData().getId());
            System.out.println("Room name :" + event.getData().getName());
            System.out.println("Room Owner : " + event.getData().getRoomOwner());
            System.out.println("Max Users : " + event.getData().getMaxUsers());
        }
    }

  /** 
   * Invoked in response to a joinRoom request. 
   * @param event 
   */ 
@Override
  public void onJoinRoomDone(RoomEvent event) {
        System.out.println("onJoinRoom :" + event.getResult());
        if (event.getResult() == WarpResponseResultCode.SUCCESS) {
            System.out.println("room Id :" + event.getData().getId());
            System.out.println("Room name :" + event.getData().getName());
            System.out.println("Room Owner : " + event.getData().getRoomOwner());
            System.out.println("Max Users : " + event.getData().getMaxUsers());
        }
    } 
 
/** 
   * Invoked in response to a leaveRoom request. 
   * @param event 
   */ 
 @Override
  public void onLeaveRoomDone(RoomEvent event) {
        System.out.println("onLeaveRoomDone :" + event.getResult());
        if (event.getResult() == WarpResponseResultCode.SUCCESS) {
            System.out.println("room Id :" + event.getData().getId());
            System.out.println("Room name :" + event.getData().getName());
            System.out.println("Room Owner : " + event.getData().getRoomOwner());
            System.out.println("Max Users : " + event.getData().getMaxUsers());
        }
    }

  /** 
   * Invoked in response to a getLiveRoomInfo request. 
   * @param event 
   */ 
 @Override
    public void onGetLiveRoomInfoDone(LiveRoomInfoEvent event) {
         System.out.println("onGetLiveRoomInfoDone:" + event.getResult());
        if (event.getResult() == WarpResponseResultCode.SUCCESS) {
            String[] users = event.getJoinedUsers();
            System.out.println("Lock Properties:" + event.getLockProperties());
            System.out.println("Properties:" + event.getProperties());
            System.out.println("Get Room ID:" + event.getData().getId());
            System.out.println("Get username:" + event.getData().getName());
            System.out.println("Get Room Owner:" + event.getData().getRoomOwner());
            System.out.println("User Length :" + users.length);
        }
    }

  /** 
   * Invoked in response to a setCustomRoomData request. 
   * @param event 
   */ 
    @Override
    public void onSetCustomRoomDataDone(LiveRoomInfoEvent event) {
        System.out.println("onSetCustomRoomDataDone:" + event.getResult());
        if (event.getResult() == WarpResponseResultCode.SUCCESS) {
            System.out.println("Lock Properties:" + event.getLockProperties());
            System.out.println("Properties:" + event.getProperties());
            System.out.println("Get Room ID:" + event.getData().getId());
            System.out.println("Get username:" + event.getData().getName());
            System.out.println("Get Room Owner:" + event.getData().getRoomOwner());
            System.out.println("custom Data:" + event.getCustomData().toString());
        }
    }

  /**  
   * Invoked in response to add property to any room 
   */
   @Override
    public void onUpdatePropertyDone(LiveRoomInfoEvent roominfo) {
        System.out.println("onUpdatePropertyDone :" + roominfo.getResult());
        if (roominfo.getResult() == WarpResponseResultCode.SUCCESS) {
            System.out.println("room Id :" + roominfo.getJoinedUsers());
            System.out.println("Properties :" + roominfo.getProperties());
            System.out.println("Lock Properties :" + roominfo.getLockProperties());
            System.out.println("room Id :" + roominfo.getData().getId());
            System.out.println("Room name :" + roominfo.getData().getName());
            System.out.println("Room Owner : " + roominfo.getData().getRoomOwner());
            System.out.println("Max Users : " + roominfo.getData().getMaxUsers());
        }
    }

  /**  
   * Invoked in response to lock property to any room 
   */
 @Override
    public void onLockPropertiesDone(byte bt) {
        System.out.println("LockPropertiesDone :" + bt);
    }

  /**  
   * Invoked in response to unlock property to any room 
   */ 
 @Override
    public void onUnlockPropertiesDone(byte bt) {
        System.out.println("UnlockPropertiesDone :" + bt);
    }

/**  
   * Invoked in response to a joinAndSubscribeRoom request.
   */ 
  @Override
    public void onJoinAndSubscribeRoomDone(RoomEvent event) {
        System.out.println("onJoinAndSubscribeRoomDone :" + event.getResult());
        System.out.println("room Id :" + event.getData().getId());
        System.out.println("Room name :" + event.getData().getName());
        System.out.println("Room Owner : " + event.getData().getRoomOwner());
        System.out.println("Max Users : " + event.getData().getMaxUsers());
    }

/**  
   * Invoked in response to a leaveAndUnsubscribeRoom request.
   */ 
 @Override
    public void onLeaveAndUnsubscribeRoomDone(RoomEvent event) {
        System.out.println("onLeaveAndUnsubscribeRoomDone:" + event.getResult());
        System.out.println("room Id :" + event.getData().getId());
        System.out.println("Room name :" + event.getData().getName());
        System.out.println("Room Owner : " + event.getData().getRoomOwner());
        System.out.println("Max Users : " + event.getData().getMaxUsers());
    }

ZoneRequestListener
  
   /** 
   * Invoked in response to a deleteRoom request. 
   * @param event 
   */ 
   @Override
    public void onDeleteRoomDone(RoomEvent event) {
        System.out.println("onDeleteRoomDone :" + event.getResult());
        if (event.getResult() == WarpResponseResultCode.SUCCESS) {
            System.out.println("RoomId : " + event.getData().getId());
            System.out.println("Room Name : " + event.getData().getName());
            System.out.println("Room Owner : " + event.getData().getRoomOwner());
            System.out.println("Room Max Users : " + event.getData().getMaxUsers());
        }
    }

  /** 
   * Invoked in response to a getAllRooms request. 
   * @param event 
   */
 @Override
    public void onGetAllRoomsDone(AllRoomsEvent event) {
        System.out.println("onGetAllRoomsDone :" + event.getResult());
        if (event.getResult() == WarpResponseResultCode.SUCCESS) {
            for (int i = 0; i < event.getRoomIds().length; i++) {
                System.out.println("RoomId " + event.getRoomIds()[i]);
            }
        }
    }

  /** 
   * Invoked in response to a createRoom request. 
   * @param event 
   */ 
 @Override
    public void onCreateRoomDone(RoomEvent event) {
        System.out.println("onCreateRoomDone " + event.getResult());
        if (event.getResult() == WarpResponseResultCode.SUCCESS) {
            System.out.println("RoomId : " + event.getData().getId());
            System.out.println("Room Name : " + event.getData().getName());
            System.out.println("Room Owner : " + event.getData().getRoomOwner());
            System.out.println("Room Max Users : " + event.getData().getMaxUsers());
        }
    }

  /** 
   * Invoked in response to a getOnlineUsers request. 
   * @param event 
   */
    @Override
    public void onGetOnlineUsersDone(AllUsersEvent event) {
        System.out.println("onGetOnlineUsersDone :" + event.getResult());
        if (event.getResult() == WarpResponseResultCode.SUCCESS) {
            for (int i = 0; i < event.getUserNames().length; i++) {
                System.out.println(event.getUserNames()[i]);
            }
        }
    }

  /** 
   * Invoked in response to a getLiveUserInfo request. 
   * @param event 
   */
 @Override
    public void onGetLiveUserInfoDone(LiveUserInfoEvent event) {
        System.out.println("onGetLiveUserInfoDone :"+event.getResult());
        if (event.getResult() == WarpResponseResultCode.SUCCESS) {
            String location = "";
            if (event.isLocationLobby()) {
                location = "the lobby";
            } else {
                location = "room id" + event.getLocationId();
            }
            System.out.println("User " + event.getName() + " is at " + location);
            System.out.println("username :"+event.getName());
         }
    }

  /** 
   * Invoked in response to a setCustomRoomData request. 
   * @param event 
   */
@Override
    public void onSetCustomUserDataDone(LiveUserInfoEvent event) {
        System.out.println("onSetCustomUserDataDone :" + event.getResult());
        if (event.getResult() == WarpResponseResultCode.SUCCESS) {
            System.out.println("Name :" + event.getName());
            System.out.println("custom Data :" + event.getCustomData());
            System.out.println("Location Lobby :" + event.isLocationLobby());
            System.out.println("custom Data :" + event.getCustomData().toString());
        }
    }  

   /** 
   * Invoked in response to a getMatchMaking Rooms request. 
   * @param event 
   */ 
 @Override
   public void onGetMatchedRoomsDone(MatchedRoomsEvent event) {
        System.out.println("onGetMatchedRoomsDone :" + event.getResult());
        if (event.getResult() == WarpResponseResultCode.SUCCESS) {
            for (int i = 0; i < event.getRoomsData().length; i++) {
                System.out.println("RoomId : " + event.getRoomsData()[i].getId());
                System.out.println("Room Name : " + event.getRoomsData()[i].getName());
                System.out.println("Room Owner : " + event.getRoomsData()[i].getRoomOwner());
                System.out.println("Room Max Users : " + event.getRoomsData()[i].getMaxUsers());
            }
        }
    }
/** 
   * Invoked in response to a getOnlineUsersCount  request. 
   * @param event 
   */ 
 @Override
    public void onGetOnlineUsersCountDone(AllUsersEvent event) {
       System.out.println("Users Count :"+event.getUsersCount());
    }

/** 
   * Invoked in response to a getAllRoomsCount  request. 
   * @param event 
   */ 
 @Override
    public void onGetAllRoomsCountDone(AllRoomsEvent event) {
       System.out.println("Rooms Count :"+event.getRoomsCount());
    }
/** 
   * Invoked in response to a getUserStatus request. 
   * @param event 
   */ 
 @Override
    public void onGetUserStatusDone(LiveUserInfoEvent event) {
       System.out.println("onGetUserStatusDone :" +event.getResult());
       System.out.println("Status :"+event.isActive());
    }
LobbyRequestListener
  
   /** 
   * Invoked in response to a joinLobby request. 
   * @param event 
   */ 
  @Override
   public void onJoinLobbyDone(LobbyEvent event) {
        System.out.println("onJoinLobbyDone  :" + event.getResult());
        if (event.getResult() == WarpResponseResultCode.SUCCESS) {
            System.out.println("Lobby name  :" + event.getInfo().getName());
            System.out.println("Lobby Owner : " + event.getInfo().getRoomOwner());
        }
    }

  /** 
   * Invoked in response to a leaveLobby request. 
   * @param event 
   */ 
  @Override
    public void onLeaveLobbyDone(LobbyEvent event) {
        System.out.println("onLeaveLobbyDone  :" + event.getResult());
        if (event.getResult() == WarpResponseResultCode.SUCCESS) {
            System.out.println("Lobby name  :" + event.getInfo().getName());
            System.out.println("Lobby Owner : " + event.getInfo().getRoomOwner());
        }
    }

  /** 
   * Invoked in response to a subscribeLobby request. 
   * @param event 
   */ 
 @Override
    public void onSubscribeLobbyDone(LobbyEvent event) {
        System.out.println("onSubscribeLobbyDone  :" + event.getResult());
        if (event.getResult() == WarpResponseResultCode.SUCCESS) {
            System.out.println("Lobby name  :" + event.getInfo().getName());
            System.out.println("Lobby Owner : " + event.getInfo().getRoomOwner());
        }
    }

  /** 
   * Invoked in response to a UnSubscribeLobby request. 
   * @param event 
   */
 @Override
    public void onUnSubscribeLobbyDone(LobbyEvent event) {
        System.out.println("onUnSubscribeLobbyDone  :" + event.getResult());
        if (event.getResult() == WarpResponseResultCode.SUCCESS) {
            System.out.println("Lobby name  :" + event.getInfo().getName());
            System.out.println("Lobby Owner : " + event.getInfo().getRoomOwner());
        }
    }

  /** 
   * Invoked in response to a getLiveLobbyInfo request. 
   * @param event 
   */
  @Override
    public void onGetLiveLobbyInfoDone(LiveRoomInfoEvent event) {
         System.out.println("onGetLiveLobbyInfoDone::" + event.getResult());
        if (event.getResult() == WarpResponseResultCode.SUCCESS) {
           String[] users = event.getJoinedUsers();
           String result = "";
           System.out.println("Users are");
            if (users.length > 0) {
                for (int i = 0; i < event.getJoinedUsers().length; i++) {
                    result += " " + users[i];
                }
            }
            System.out.println(result);
        }
    }
UpdateRequestListener
  
 /** 
   * Result of SendUpdatePeers request. The result value maps to a WarpResponseResultCode 
   * @param result 
   */ 
@Override
    public void onSendUpdateDone(byte result) {
       System.out.println("onSendUpdateDone  :result " + result);
    }

   /**
   * Result of SendPrivateUpdate request. The result value maps to a WarpResponseResultCode 
   * @param result 
   */ 
 @Override
    public void onSendPrivateUpdateDone(byte result) {
        System.out.println("onSendPrivateUpdateDone  :result " + result);
    }
ChatRequestListener
  
   /** 
   * Result of sendChat request. The result value maps to a WarpResponseResultCode 
   * @param result 
   */
 @Override
    public void onSendChatDone(byte result) {
        System.out.println("onSendChatDone  :result " + result);
    }

  /** 
   * Invoked when a response for sendPrivateChat is received. Result of the  
   * operation is passed as an argument of value WarpResponseResultCode. 
   * @param result 
   */ 
 @Override
    public void onSendPrivateChatDone(byte result) {
         System.out.println("onSendPrivateChatDone  :result " + result);
    }

 /** 
   * Invoked when a response for getChatHistory is received. Result of the  
   * operation is passed as an argument of value WarpResponseResultCode. 
   * @param result 
   *  @param chatHistory
   */ 
 @Override
    public void onGetChatHistoryDone(byte result,
            ArrayList chatHistory) {
        if(result==WarpResponseResultCode.SUCCESS){
            for(ChatEvent chatEvent:chatHistory){
                System.out.println("Sender :" +chatEvent.getSender());
                System.out.println("Meesage :" +chatEvent.getMessage());
                System.out.println("Time Stamp :" +chatEvent.getTime());
            }
            }
            else{
                System.out.println("Error Code:" +result);
            }
    }
    
NotifyListener
  
   /** 
   * Invoked when a room is created. Lobby subscribers will receive this. 
   * @param event 
   */ 
   @Override
    public void onRoomCreated(RoomData event) {
        System.out.println("room " + event.getName() + " created with id " + event.getId());
    }

  /** 
   * Invoked when a room is deleted. Lobby subscribers will receive this. 
   * @param event 
   */ 
   @Override
    public void onRoomDestroyed(RoomData event) {
        System.out.println("room " + event.getName() + " destroyed with id " + event.getId());
    }

  /** 
   * Invoked when a user leaves a room. Lobby and the concerned room subscribers  
   * will receive this. 
   * @param event 
   * @param username 
   */ 
   @Override
    public void onUserLeftRoom(RoomData event, String username) {
       System.out.println(username + " left room " + event.getName());
    }

  /** 
   * Invoked when a user joins a room. Lobby and the concerned room subscribers  
   * will receive this. 
   * @param event 
   * @param username 
   */ 
   @Override
    public void onUserJoinedRoom(RoomData event, String username) {
        System.out.println(username + " joined room " + event.getName());
    }

  /** 
   * Invoked when a user leaves a lobby. Lobby subscribers will receive this. 
   * @param event 
   * @param username 
   */ 
  @Override
    public void onUserLeftLobby(LobbyData event, String username) {
        System.out.println(username + " left the lobby");
    } 
 
  /** 
   * Invoked when a user joins a lobby. Lobby subscribers will receive this. 
   * @param event 
   * @param username 
   */ 
   @Override
    public void onUserJoinedLobby(LobbyData event, String username) {
        System.out.println(username + " joined the lobby");
    }

  /** 
   * Invoked when a joined user sends a chat. Rooms subscribers will receive this. 
   * @param event 
   */ 
   @Override
    public void onChatReceived(ChatEvent event) {
        String location = "";
        if (event.isLocationLobby()) {
            location = "the lobby";
        } else {
            location = "room id" + event.getLocationId();
        }
        System.out.println("sender name :" + event.getSender());
        System.out.println("Room ID :" + event.getLocationId());
        System.out.println("Message  :" + event.getMessage());
        System.out.println(event.getSender() + " says " + event.getMessage() + " in " + location);
    }

  /** 
   * Invoked when a private chat is received from the given sender. 
   * @param sender 
   * @param message 
   */ 
  @Override
    public void onPrivateChatReceived(String sender , String message) {
        System.out.println("onPrivateChat room " + sender + " chat" + message);
    }

  /** 
   * Invoked when a updatePeers request is sent in one of the subscribed rooms. 
   * @param event 
   */ 
    @Override
    public void onUpdatePeersReceived(UpdateEvent event) {
        String s = new String(event.getUpdate());
        System.out.println("Message : " + s);
        System.out.println("update received " + event.getUpdate());
    }

 /** 
   * Invoked when user receives private update data 
   *  @param sender
   *  @param update
   *  @param fromUdp
 */ 
   @Override
    public void onPrivateUpdateReceived(String sender, byte[] update, boolean fromUdp) {
        System.out.println("username :"+sender);
        System.out.println("Tcp = false or UDP = true :"+fromUdp);
        String s = new String(update);
        System.out.println("Message : " + s);
    }

  /** 
   * Invoked when a user changes the properties of a subscribed room property.  
   * @param event 
   * @param username 
   * @param properties 
   * @param lockProperties 
   */ 
  @Override
    public void onUserChangeRoomProperty(RoomData event, String username, HashMap properties,HashMap lockProperties) {
        System.out.println("id :"+event.getId());
        System.out.println("Max users :"+event.getMaxUsers());
        System.out.println("Name :"+event.getName());
        System.out.println("Room Owner :"+event.getRoomOwner());
        System.out.println(properties.toString());
        System.out.println(lockProperties.toString());
        System.out.println("Change Property " + event.getName() + " " + username );
    }

  /** 
   * Invoked when a user's move is completed in a turn based room 
   * @param moveEvent 
   */ 
     @Override
    public void onMoveCompleted(MoveEvent event) {
        System.out.println("getMoveData :"+event.getMoveData());
        System.out.println("getNextTurn :"+event.getNextTurn());
        System.out.println("getRoomId :"+event.getRoomId());
        System.out.println("getSender :"+event.getSender());
    }

    /**
     * Invoked when a user's start game in a turn based room
     */
    @Override
    public void onGameStarted(String username, String roomID, String roomOwner) {
        System.out.println("Game Started " + username + " " + roomID + " " + roomOwner);
    }
    
    /**
     * Invoked when a user's stop game in a turn based room
     */
   @Override
    public void onGameStopped(String username, String roomID) {
        System.out.println("Game Stopped " + username + "  " roomID " + roomID);
    }
    
    /**
     * Invoked to indicate that a user has lost connectivity. Subscribers of the users location 
     * will receive this.
     * @param locid
     * @param isLobby
     * @param username
     */
    @Override
     public void onUserPaused(String locid, boolean isLobby, String username);
        System.out.println("User Paused " + locid+ " " + username);
    }

    /**
     * Invoked when a user's connectivity is restored. Subscribers of the users location 
     * will receive this.
     * @param locid
     * @param isLobby 
     * @param username
     */

    @Override
    public void onUserResumed(String locid, boolean isLobby, String username) {
        System.out.println("User Resumed " + locid+ " " + username);
    }

    /**
     * Invoked when a request from the server is received to set the next turn
     * @param lastTurn 
     */
    @Override
    public void onNextTurnRequest(String lastTurn) {
          System.out.println("lastTurn " + lastTurn);
    }

TurnBasedRoomListener
    /**
     * Invoked when a response from the server for SendMove request is received
     * @param result 
     */
   @Override
    public void onSendMoveDone(byte result) {
      System.out.println("onSendMoveDone   :result " + result);
    }
    
    /**
     * Invoked when a response from the server for StartGame request is received
     * @param result 
     */
@Override
    public void onStartGameDone(byte result) {
      System.out.println("onStartGameDone   :result " + result);
    }
    
    /**
     * Invoked when a response from the server for StopGame request is received
     * @param result 
     */
    @Override
    public void onStopGameDone(byte result) {
      System.out.println("onStopGameDone   :result " + result);
    }

    /**
     * Invoked when a response from the server for GetMoveHistory request is received
     * @param result
     * @param moves array of moves representing the history if response is success.
     */
 @Override
    public void onGetMoveHistoryDone(byte result, MoveEvent[] moves) {
         System.out.println("onGetMoveHistoryDone    :result " + result);
    }

    /**
     * Invoked when a response from the server for setNextTurn request is received
     * @param result 
     */
  @Override
    public void onSetNextTurnDone(byte result) {
       System.out.println("onSetNextTurnDone    :result " + result);
    }