Page 1 of 1

Understand onObjectMessage on ios

Posted: 27 Jun 2013, 04:01
by hoangdoanh
Hi all

In description of onObjectMessage on Xcode, I see this information
This event is fired every time a server-side Extension sends a message, usually in response to an ExtensionRequest.

But actually below function does not run, and onObjectMessage was not fired on the client side when client got server messages.

Code: Select all

-(void)onObjectMessage:(SFSEvent *)evt;
Concretely it happened for following messages that server sent by ClientRequest Handler and by extension class

---[on Client Request Handler : send("restart",obj,gameExt.getPlayerList());
---on Extension class : send("start", resObj,this.playerList );
---on Extension class : send("finish",gameBoard.getResultObject(),this.playerList);

Instead of got onObjectMessage is fired, The following function was fired on messages got from server.

Code: Select all

- (void)onExtensionResponse:(SFSEvent *)evt
{
    //NSLog(@"Got server message");
    NSString    *   cmd=[evt.params objectForKey:@"cmd"];
    
    
    if([cmd isEqualToString:@"start"])
    {
        
        SFSObject   *   resObj=[evt.params objectForKey:@"params"];
        NSString *  p1Name=[resObj getUtfString:@"p1n"];
        NSString *  p2Name=[resObj getUtfString:@"p2n"];
        if([self.myName isEqualToString:p1Name])
        {
            [self.gameBoard setName:p1Name op:p2Name ] ;
        }
        else
        {
            [self.gameBoard setName:p2Name op:p1Name ] ;
        }
        
        [self.gameBoard startGame] ;
    }
    else
        if([cmd isEqualToString:@"finish"])
        {
            SFSObject   *   resObj=[evt.params objectForKey:@"params"];
            //[self.gameBoard executeResult:resObj ] ;
            [self.gameBoard performSelector:@selector(executeResult:) withObject:resObj afterDelay:5];
            
        }
    else
        if([cmd isEqualToString:@"restart"])
        {
            [gameBoard resetGameBoard];
        }
}


So now I really don't understand when onObjectMessage works, don't understand on which event it will be fired.

Anyone can help me to clarify this

Thank you very much

Doanh

Re: Understand onObjectMessage on ios

Posted: 27 Jun 2013, 07:30
by Lapo
The online documentation says:
Discussion
This event is received when a User has sent an ObjectMessage request

The object sent by the sender can contain custom data, such as a game move etc…
In other words the event is in response to a SendObjectMessage request.

Are you sure you are not consulting an old version of the documentation?
http://docs2x.smartfoxserver.com/api-do ... ectMessage:

Re: Understand onObjectMessage on ios

Posted: 27 Jun 2013, 09:03
by hoangdoanh
Thanks Lapo

I got it. I read this information from files ISFSEvents.h in SFS2XAPIIOS.framework.

Framework version is 1.5.5 . Is it updated ?

Doanh

Re: Understand onObjectMessage on ios

Posted: 27 Jun 2013, 12:06
by Lapo
1.1.5 is the latest version.
http://www.smartfoxserver.com/download/sfs2x#p=client
The documentation is found online at the address I gave you before

Re: Understand onObjectMessage on ios

Posted: 28 Jun 2013, 03:19
by hoangdoanh
Thank you Lapo

Best regards,

Doanh