How to check extension request object from server?

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

Moderators: Lapo, Bax

crosskid
Posts: 36
Joined: 30 Oct 2012, 07:56

How to check extension request object from server?

Postby crosskid » 08 Nov 2012, 04:27

Hi, in server side i'm sending request handler like this

// Obtain a resultset
ISFSArray res = dbManager.executeQuery(sql);

// Populate the response parameters
ISFSObject response = new SFSObject();
response.putSFSArray("userData", res);

// Send back to requester
send("checkPlayerExist", response, sender);

the question is, in onExtensionResponse:(SFSEvent *)evt method on client side, how do i check if the "userData" is exist or the kind of extension request is "checkPlayerExist"?
thank you
User avatar
Bax
Site Admin
Posts: 4612
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Re: How to check extension request object from server?

Postby Bax » 08 Nov 2012, 10:09

Please check the API documentation: http://docs2x.smartfoxserver.com/api-do ... onResponse:
As you can see the cmd parameter on the event object contains the name of the response sent by the server, in your case "checkPlayerExist".
In the params parameter you will then find that "userData" object.
Paolo Bax
The SmartFoxServer Team
crosskid
Posts: 36
Joined: 30 Oct 2012, 07:56

Re: How to check extension request object from server?

Postby crosskid » 08 Nov 2012, 11:36

ah, i figured it out

in onExtensionResponse method i write like this

Code: Select all

-(void)onExtensionResponse:(SFSEvent *)evt
{
    SFSObject *data = (SFSObject*)evt.params[@"params"];

    //check with "containsKey" function if "userData" array exist
    if ([data containsKey:@"userData"])
    {
       //do something
    }
}


thanks Bax

Return to “SFS2X iPhone / iPad / OSX API”

Who is online

Users browsing this forum: No registered users and 39 guests