objective-c-client-listener

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

iOS Client Listeners

Connection Request Listener
    /** * Invoked in response to a connect request. * @param event */ 
    -(void)onConnectDone:(ConnectEvent *)event{
        NSLog(@"onConnectDone = %d",event.result);
        if (event.result == SUCCESS){
            NSLog(@"Connected Successfully");
        }else if(event.result == AUTH_ERROR){
            NSLog(@"ReasonCode = %d",event.reasonCode);
            // It comes due to wrong API keys or userName passed is already taken by someone else
        }else if(event.result == CONNECTION_ERR){
            // It comes due to network error
            // You can call connect API once network resumed
        }else if(event.result == BAD_REQUEST){
            // It comes due to bad parameter passed or this request is not valid
        }else if(event.result == CONNECTION_ERROR_RECOVERABLE){
            // It comes in case of network error if recovery allowance time is set
            // You should call recoverConnection here, better to give some time inetrval between subsequent recoverConnection calls
        }else if(event.result == SUCCESS_RECOVERED){
            // It comes if connection was recovered after recoverConnection was called
        }else if(event.result == AUTO_RECOVERING){
            // It comes if Auto recovery is enabled in App settings in the AppHQ dashboard
        }else{   
        }
    }
    /** * Invoked in response to a disconnect request. * @param event */ 
    -(void)onDisconnectDone:(ConnectEvent *)event{
        if (event.result == SUCCESS) {
            NSLog(@"Disconnected succesfully");
        }else{
            //Handle exception while disconnecting
        }
    }
    /** * Invoked in response to a init UDP request. * @param result */
    -(void)onInitUDPDone:(Byte)result{
        if (result == SUCCESS) {
            //Handle success response
        }else{
            //Handle failed response
        }
    }
Room Request Listener
    /** * Invoked in response to a subscribeRoom request. * @param event */ 
    -(void)onSubscribeRoomDone:(RoomEvent *)roomEvent{
        if (roomEvent.result == SUCCESS) {
            //Handle Success response here
            NSLog(@"Room Name = %@",roomEvent.roomData.name);
            NSLog(@"Room ID = %@",roomEvent.roomData.roomId);
            NSLog(@"Room Owner = %@",roomEvent.roomData.owner);
            NSLog(@"Max Allowed Users = %d",roomEvent.roomData.maxUsers);
        }else{
            //Handle Failed response here
        }
    }
    /** * Invoked in response to a UnSubscribeRoom request. * @param event */ 
    -(void)onUnSubscribeRoomDone:(RoomEvent *)roomEvent{
        if (roomEvent.result == SUCCESS) {
            //Handle Success response here
            NSLog(@"Room Name = %@",roomEvent.roomData.name);
            NSLog(@"Room ID = %@",roomEvent.roomData.roomId);
            NSLog(@"Room Owner = %@",roomEvent.roomData.owner);
            NSLog(@"Max Allowed Users = %d",roomEvent.roomData.maxUsers);
        }else{
            //Handle Failed response here
        }
    }
    /** * Invoked in response to a joinRoom request. * @param event */ 
    -(void)onJoinRoomDone:(RoomEvent *)roomEvent{
        if (roomEvent.result == SUCCESS) {
            //Handle Success response here
            NSLog(@"Room Name = %@",roomEvent.roomData.name);
            NSLog(@"Room ID = %@",roomEvent.roomData.roomId);
            NSLog(@"Room Owner = %@",roomEvent.roomData.owner);
            NSLog(@"Max Allowed Users = %d",roomEvent.roomData.maxUsers);
        }else{
            //Handle Failed response here
        }
    }
    /** * Invoked in response to a leaveRoom request. * @param event */ 
    -(void)onLeaveRoomDone:(RoomEvent *)roomEvent{
        if (roomEvent.result == SUCCESS) {
            //Handle Success response here
            NSLog(@"Room Name = %@",roomEvent.roomData.name);
            NSLog(@"Room ID = %@",roomEvent.roomData.roomId);
            NSLog(@"Room Owner = %@",roomEvent.roomData.owner);
            NSLog(@"Max Allowed Users = %d",roomEvent.roomData.maxUsers);
        }else{
            //Handle Failed response here
        }
    }
    /** * Invoked in response to a getLiveRoomInfo request. * @param event */ 
    -(void)onGetLiveRoomInfoDone:(LiveRoomInfoEvent *)event{
        if (event.result == SUCCESS) {
            //Handle Success response here
            NSLog(@"Room Name = %@",event.roomData.name);
            NSLog(@"Room ID = %@",event.roomData.roomId);
            NSLog(@"Room Owner = %@",event.roomData.owner);
            NSLog(@"Max Allowed Users = %d",event.roomData.maxUsers);
            NSLog(@"Joined Users = %@",event.joinedUsers);
            NSLog(@"Porperties: %@",event.properties);
            NSLog(@"Lock Properties: %@",event.lockPropeties);
            NSLog(@"Custom Room Data = %@",event.customData);
        }else{
            //Handle Failed response here
        }
    }
    /** * Invoked in response to a setCustomRoomData request. * @param event */ 
    -(void)onSetCustomRoomDataDone:(LiveRoomInfoEvent *)event{
        if (event.result == SUCCESS) {
            //Handle Success response here
            NSLog(@"Room Name = %@",event.roomData.name);
            NSLog(@"Room ID = %@",event.roomData.roomId);
            NSLog(@"Room Owner = %@",event.roomData.owner);
            NSLog(@"Max Allowed Users = %d",event.roomData.maxUsers);
            NSLog(@"Joined Users = %@",event.joinedUsers);
            NSLog(@"Porperties: %@",event.properties);
            NSLog(@"Lock Properties: %@",event.lockPropeties);
            NSLog(@"Custom Room Data = %@",event.customData);
        }else{
            //Handle Failed response here
        }
    }
    /** * Invoked in response to a updateRoomProperties request. * @param event */ 
    -(void)onUpdatePropertyDone:(LiveRoomInfoEvent *)event{
        if (event.result == SUCCESS) {
            //Handle Success response here
            NSLog(@"Room Name = %@",event.roomData.name);
            NSLog(@"Room ID = %@",event.roomData.roomId);
            NSLog(@"Room Owner = %@",event.roomData.owner);
            NSLog(@"Max Allowed Users = %d",event.roomData.maxUsers);
            NSLog(@"Joined Users = %@",event.joinedUsers);
            NSLog(@"Porperties: %@",event.properties);
            NSLog(@"Lock Properties: %@",event.lockPropeties);
            NSLog(@"Custom Room Data = %@",event.customData);
        }else{
            //Handle Failed response here
        }
    } 
    /* * Invoked in response to lock room property to any room. * @param result */ 
    -(void)onLockPropertiesDone:(Byte)result{
        if (result == SUCCESS) {
            //Handle Success response here
        }else{
            //Handle Failed response here
        }
    }
    /* * Invoked in response to unlock room property to any room. * @param result */ 
    -(void)onUnlockPropertiesDone:(Byte)result{
        if (result == SUCCESS) {
            //Handle Success response here
        }else{
            //Handle Failed response here
        }
    }
    /* * Invoked in response to leaveAndUnsubscribeRoom. *@param roomEvent */
    -(void)onLeaveAndUnsubscribeRoomDone:(RoomEvent *)roomEvent{
        if (roomEvent.result == SUCCESS) {
            //Handle Success response here
            NSLog(@"Room Name = %@",roomEvent.roomData.name);
            NSLog(@"Room ID = %@",roomEvent.roomData.roomId);
            NSLog(@"Room Owner = %@",roomEvent.roomData.owner);
            NSLog(@"Max Allowed Users = %d",roomEvent.roomData.maxUsers);
        }else{
            //Handle Failed response here
        }
    }
    /* * Invoked in response to joinAndSubscribeRoom. *@param roomEvent */
    -(void)onJoinAndSubscribeRoomDone:(RoomEvent *)roomEvent{
        if (roomEvent.result == SUCCESS) {
            //Handle Success response here
            NSLog(@"Room Name = %@",roomEvent.roomData.name);
            NSLog(@"Room ID = %@",roomEvent.roomData.roomId);
            NSLog(@"Room Owner = %@",roomEvent.roomData.owner);
            NSLog(@"Max Allowed Users = %d",roomEvent.roomData.maxUsers);
        }else{
            //Handle Failed response here
        }
    }

    
Zone Request Listener
    /** * Invoked in response to a deleteRoom request. * @param event */ 
    -(void)onDeleteRoomDone:(RoomEvent *)roomEvent{
        if (roomEvent.result == SUCCESS) {
            //Room deleted successfully
        }else{
            //Handle exceptions here which may be bad_request etc.
        }
    }
    /** * Invoked in response to a getAllRooms request. * @param event */ 
    -(void)onGetAllRoomsDone:(AllRoomsEvent *)event{
        if (event.result == SUCCESS) {
            for (NSString *roomId in event.roomIds) {
                NSLog(@"RoomID : %@",roomId);
            }
        }else{
            //Handle exceptions here which may be bad_request etc.
        }
    }
    /** * Invoked in response to a createRoom request. * @param event */ 
    -(void)onCreateRoomDone:(RoomEvent *)roomEvent{
        if (roomEvent.result == SUCCESS) {
            NSLog(@"Room Name = %@",roomEvent.roomData.name);
            NSLog(@"Room ID = %@",roomEvent.roomData.roomId);
            NSLog(@"Room Owner = %@",roomEvent.roomData.owner);
            NSLog(@"Max allowed Users = %d",roomEvent.roomData.maxUsers);
        }else{
            //Handle exceptions here which may be bad_request etc.
        }
    }
    /** * Invoked in response to a getOnlineUsers request. * @param event */ 
    -(void)onGetOnlineUsersDone:(AllUsersEvent *)event
    {
        if (event.result == SUCCESS) {
            for (NSString *userName in event.userNames) {
                NSLog(@"User Name : %@",userName);
            }
        }else{
            //Handle exceptions here which may be bad_request,connection_error etc.
        }
    }
    /** * Invoked in response to a getLiveUserInfo request. * @param event */ 
    -(void)onGetLiveUserInfoDone:(LiveUserInfoEvent *)event{
        if (event.result == SUCCESS) {
            NSLog(@"User Name = %@",event.name);
            NSLog(@"LocationID = %@",event.locationId);
            NSLog(@"CustomData = %@",event.customData);
        }else{
            //Handle exceptions here which may be bad_request etc.
        }
    }
    /** * Invoked in response to a setCustomRoomData request. * @param event */ 
    -(void)onSetCustomUserDataDone:(LiveUserInfoEvent *)event{
        if (event.result == SUCCESS) {
            NSLog(@"CustomData = %@", event.customData);
        }else{
            //Handle exceptions here which may be bad_request,connection_error etc.
        }
    }
    /** * Invoked in response to a getMatchMaking Rooms request. * @param event */ 
    -(void)onGetMatchedRoomsDone:(MatchedRoomsEvent *)event{
        NSLog(@"%s",__func__);
        if (event.result == SUCCESS) {
            for (RoomData *roomData in event.roomData) {
                NSLog(@"Room Name = %@",roomData.name);
                NSLog(@"Room ID = %@",roomData.roomId);
                NSLog(@"Room Owner = %@",roomData.owner);
                NSLog(@"Max allowed Users = %d",roomData.maxUsers);
            }
        }else{
            NSLog(@"Error Code = %d",event.result);
            //Handle exceptions here which may be bad_request,connection_error etc.
        }
    }
    /** * Invoked in response to getUserStatus. * @param event */ 
    -(void)onGetUserStatusDone:(LiveUserInfoEvent *)event{
        if (event.result == SUCCESS) {
            NSLog(@"User Name = %@",event.name);
            NSLog(@"Status = %d",event.isOnilne);
        }else{
            //Handle exceptions here which may be bad_request,connection_error etc.
        }
    }
    /** * Invoked in response to getOnlineUsersCount. * @param event */
    -(void)onGetOnlineUsersCountDone:(AllUsersEvent *)event{
        if (event.result == SUCCESS) {
            NSLog(@"Total online users = %ld",event.onlineUsersCount);
        }else{
            //Handle exceptions here which may be bad_request,connection_error etc.
        }
    }
    /** * Invoked in response to getAllRoomsCount. * @param event */
    -(void)onGetAllRoomsCountDone:(AllRoomsEvent *)event{
        if (event.result == SUCCESS) {
            NSLog(@"Total Rooms = %ld",event.roomsCount);
        }else{
            //Handle exceptions here which may be bad_request,connection_error etc.
        }
    }
Lobby Request Listener
    /** * Invoked in response to a joinLobby request. * @param event */ 
    -(void)onJoinLobbyDone:(LobbyEvent *)lobbyEvent{
        if (lobbyEvent.result == SUCCESS) {
            NSLog(@"Joined successfully");
            NSLog(@"Name = %@",lobbyEvent.info.name);
            NSLog(@"Owner = %@",lobbyEvent.info.owner);
        }else{
            //Handle Exceptions here
        }
    }
    /** * Invoked in response to a leaveLobby request. * @param event */ 
    -(void)onLeaveLobbyDone:(LobbyEvent *)lobbyEvent{
        if (lobbyEvent.result == SUCCESS) {
            NSLog(@"Left lobby successfully");
            NSLog(@"Name = %@",lobbyEvent.info.name);
            NSLog(@"Owner = %@",lobbyEvent.info.owner);
        }else{
            //Handle Exceptions here
        }
    }
    /** * Invoked in response to a subscribeLobby request. * @param event */ 
    -(void)onSubscribeLobbyDone:(LobbyEvent *)lobbyEvent{
        if (lobbyEvent.result == SUCCESS) {
            NSLog(@"Subscribed to lobby successfully");
            NSLog(@"Name = %@",lobbyEvent.info.name);
            NSLog(@"Owner = %@",lobbyEvent.info.owner);
        }else{
            //Handle Exceptions here
        }
    }
    /** * Invoked in response to a UnSubscribeLobby request. * @param event */ 
    -(void)onUnSubscribeLobbyDone:(LobbyEvent *)lobbyEvent{
        if (lobbyEvent.result == SUCCESS) {
            NSLog(@"UnSubscribed to lobby successfully");
            NSLog(@"Name = %@",lobbyEvent.info.name);
            NSLog(@"Owner = %@",lobbyEvent.info.owner);
        }else{
            //Handle Exceptions here
        }
    }
 
    /** * Invoked in response to a getLiveLobbyInfo request. * @param event */ 
    -(void)onGetLiveLobbyInfoDone:(LiveRoomInfoEvent *)event{
        if (event.result == SUCCESS) {
            NSLog(@"Joined Users = %@",event.joinedUsers);
        }else{
            //Handle Exceptions here
        }
    }
Update Request Listener
    /** * Result of SendPrivateUpdate request. The result value maps to a WarpResponseResultCode * @param result */ 
    -(void)onSendPrivateUpdateDone:(Byte)result{
        if (result == SUCCESS) {
            NSLog(@"Update Sent successfully");
        }else{
            //Handle exceptions here
        }
    }
    /** * Result of SendUpdatePeers request. The result value maps to a WarpResponseResultCode * @param result */ 
    -(void)onSendUpdatePeersDone:(Byte)result{
        if (result == SUCCESS) {
            NSLog(@"Update Sent successfully");
        }else{
            //Handle exceptions here
        }
    } 
Chat Request Listener
    /** * Result of SendChat request. The result value maps to a WarpResponseResultCode * @param result */ 
    -(void)onSendChatDone:(Byte)result{
        if (result == SUCCESS) {
            NSLog(@"Chat Sent successfully");
        }else{
            //Handle exceptions here
        }
    }
    /** * Invoked when a response for sendPrivateChat is received. Result of the  * operation is passed as an argument of value WarpResponseResultCode. * @param result */ 
    -(void)onSendPrivateChatDone:(Byte)result{
        if (result == SUCCESS) {
            NSLog(@"Private chat Sent successfully");
        }else{
            //Handle exceptions here
        }
    } 
Notify Listener
    /** Invoked when a room is created. Lobby subscribers will receive this. * @param event */ 
    -(void)onRoomCreated:(RoomData *)roomData{
        NSLog(@"Room Name = %@",roomData.name);
        NSLog(@"Room ID = %@",roomData.roomId);
        NSLog(@"Room Owner = %@",roomData.owner);
        NSLog(@"Max Allowed Users = %d",roomData.maxUsers);
    }
    /** Invoked when a room is deleted. Lobby subscribers will receive this. * @param event */ 
    -(void)onRoomDestroyed:(RoomData *)roomData{
        NSLog(@"Room Name = %@",roomData.name);
        NSLog(@"Room ID = %@",roomData.roomId);
        NSLog(@"Room Owner = %@",roomData.owner);
        NSLog(@"Max Allowed Users = %d",roomData.maxUsers);
    } 
    /** Invoked when a user leaves a room. Lobby and the concerned room subscribers  * will receive this. * @param event * @param username */ 
    -(void)onUserLeftRoom:(RoomData *)roomData username:(NSString *)username{
        NSLog(@"Room Name = %@",roomData.name);
        NSLog(@"Room ID = %@",roomData.roomId);
        NSLog(@"Room Owner = %@",roomData.owner);
        NSLog(@"Max Allowed Users = %d",roomData.maxUsers);
        NSLog(@"User Name = %@",username);
    }
    /** Invoked when a user joins a room. Lobby and the concerned room subscribers  * will receive this. * @param event * @param username */ 
    -(void)onUserJoinedRoom:(RoomData *)roomData username:(NSString *)username{
        NSLog(@"Room Name = %@",roomData.name);
        NSLog(@"Room ID = %@",roomData.roomId);
        NSLog(@"Room Owner = %@",roomData.owner);
        NSLog(@"Max Allowed Users = %d",roomData.maxUsers);
        NSLog(@"User Name = %@",username);
    }
    /** Invoked when a user leaves a lobby. Lobby subscribers will receive this. * @param event * @param username */ 
    -(void)onUserLeftLobby:(LobbyData *)lobbyData username:(NSString *)username{
        NSLog(@"User Name = %@",username);
    } 
    /** Invoked when a user joins a lobby. Lobby subscribers will receive this. * @param event * @param username */ 
    -(void)onUserJoinedLobby:(LobbyData *)lobbyData username:(NSString *)username{
        NSLog(@"User Name = %@",username);
    }
    /** Invoked when a joined user sends a chat. Rooms subscribers will receive this. * @param event */ 
    -(void)onChatReceived:(ChatEvent *)chatEvent{
        NSLog(@"Sender = %@",chatEvent.sender);
        NSLog(@"Message = %@",chatEvent.message);
        NSLog(@"LocId = %@",chatEvent.locId);
        NSLog(@"isLocationLobby = %d",chatEvent.isLocationLobby);
    }
    /** Invoked when a private chat is received from the given sender. * @param sender * @param message */ 
    -(void)onPrivateChatReceived:(NSString *)message fromUser:(NSString *)senderName{
        NSLog(@"Sender = %@",senderName);
        NSLog(@"Message = %@",message);
    }
    /** Invoked when a joined user sends a updatePeers request. Rooms subscribers will receive this. * @param event */ 
    -(void)onUpdatePeersReceived:(UpdateEvent *)updateEvent{
        NSLog(@"Message = %@",updateEvent.update);
    }
    /** Invoked when a user's move is completed in a turn based room. Rooms subscribers will receive this. * @param moveEvent */ 
    -(void)onMoveCompleted:(MoveEvent *)moveEvent{
        NSLog(@"Sender = %@",moveEvent.sender);
        NSLog(@"RoomID = %@",moveEvent.roomId);
        NSLog(@"Move Data =  %@",moveEvent.moveData);
        NSLog(@"Name of user whose turn is next = %@",moveEvent.nextTurn);
    }
    /** Invoked when a user change room property. Lobby and the concerned room subscribers will receive this. * @param event * @param username * @param properties * @param lockedProperties */
    -(void)onUserChangeRoomProperty:(RoomData *)roomData username:(NSString *)username properties:(NSDictionary *)properties lockedProperties:(NSDictionary *)lockedProperties{
        NSLog(@"Room Name = %@",roomData.name);
        NSLog(@"Room ID = %@",roomData.roomId);
        NSLog(@"Room Owner = %@",roomData.owner);
        NSLog(@"Max Allowed Users = %d",roomData.maxUsers);
        NSLog(@"User Name = %@",username);
        NSLog(@"Properties = %@",properties);
        NSLog(@"LockedProperties = %@",lockedProperties);
    }
    /** Invoked to indicate that a user has lost connectivity. Subscribers of the users location will receive this. * @param locid * @param isLobby * @param username */
    -(void)onUserPaused:(NSString *)userName withLocation:(NSString *)locId isLobby:(BOOL)isLobby{
        NSLog(@"User Name = %@",userName);
        NSLog(@"Location ID = %@",locId);
        NSLog(@"isLobby = %d",isLobby);
    }
   /** * Invoked when a user's connectivity is restored. Subscribers of the users location will receive this. * @param locid * @param isLobby * @param username */
    -(void)onUserResumed:(NSString *)userName withLocation:(NSString *)locId isLobby:(BOOL)isLobby{
        NSLog(@"User Name = %@",userName);
        NSLog(@"Location ID = %@",locId);
        NSLog(@"isLobby = %d",isLobby);
    }
    /** * Invoked when a user starts game in a turn based room */
   -(void)onGameStarted:(NSString *)sender roomId:(NSString *)roomId nextTurn:(NSString *)nextTurn{
        NSLog(@"Sender = %@",sender);
        NSLog(@"RoomID = %@",roomId);
        NSLog(@"Name of user whose turn is next = %@",nextTurn);
    }
    /** * Invoked when a user stops game in a turn based room */
   -(void)onGameStopped:(NSString *)sender roomId:(NSString *)roomId{
        NSLog(@"Sender = %@",sender);
        NSLog(@"RoomID = %@",roomId);
    }
Turn Based Room Listener
    /** *  Invoked when a response for a sendMove request is received. The result value maps to a WarpResponseResultCode * @param result */ 
    -(void)onSendMoveDone:(Byte)result{
        if (result == SUCCESS) {
            NSLog(@"Move Sent successfully");
        }else{
            //Handle exceptions here
        }
    }
   /** * Invoked when a response for a startGame request is received. Room subscribers will receive this. * @param result */
    -(void)onStartGameDone:(Byte)result{
        if (result == SUCCESS) {
            NSLog(@"Game started successfully");
        }else{
            //Handle exceptions here
        }
    }
   /** * Invoked when a response for a stopGame request is received. Room subscribers will receive this. * @param result */
    -(void)onStopGameDone:(Byte)result{
        if (result == SUCCESS) {
            NSLog(@"Game stopped successfully");
        }else{
            //Handle exceptions here
        }
    }
   /** * Invoked when a response for a getMoveHistory request is received. * @param result */
    -(void)onGetMoveHistoryDone:(Byte)result moves:(NSMutableArray *)movesArray{
        if (result == SUCCESS) {
            NSLog(@"MoveHistory = %@",movesArray);
        }else{
            //Handle exceptions here
        }
    }