Understand onObjectMessage on ios

Post here your questions about the Objective-C API for SFS2X

Moderators: Lapo, Bax

User avatar
hoangdoanh
Posts: 253
Joined: 21 Jun 2013, 04:54
Location: Vietnam

Understand onObjectMessage on ios

Postby hoangdoanh » 27 Jun 2013, 04:01

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
User avatar
Lapo
Site Admin
Posts: 23027
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Understand onObjectMessage on ios

Postby Lapo » 27 Jun 2013, 07:30

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:
Lapo
--
gotoAndPlay()
...addicted to flash games
User avatar
hoangdoanh
Posts: 253
Joined: 21 Jun 2013, 04:54
Location: Vietnam

Re: Understand onObjectMessage on ios

Postby hoangdoanh » 27 Jun 2013, 09:03

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
User avatar
Lapo
Site Admin
Posts: 23027
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Understand onObjectMessage on ios

Postby Lapo » 27 Jun 2013, 12:06

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
Lapo

--

gotoAndPlay()

...addicted to flash games
User avatar
hoangdoanh
Posts: 253
Joined: 21 Jun 2013, 04:54
Location: Vietnam

Re: Understand onObjectMessage on ios

Postby hoangdoanh » 28 Jun 2013, 03:19

Thank you Lapo

Best regards,

Doanh

Return to “SFS2X iPhone / iPad / OSX API”

Who is online

Users browsing this forum: No registered users and 49 guests