Page 1 of 1

sendXtMessage usage

Posted: 21 Oct 2009, 03:25
by aw2xcd
Hi Guys,

Not sure if this is a bug or if I'm using this wrong. Anyways, when I use

Code: Select all

//This function basically returns start time object.
[smartFox sendXtMessage:@"timeEx" cmd:@"gst" paramObj:nil type: @"xml" roomId:1];
I get a server error, however if I use it with type: @"str" it works but obviously I don't have access to returned values.
Also it cuts out the first letter of the returned _cmd somehow.


As mentioned in the bugs thread I believe it has something to do with the passed in paramObj being null.
So I tried the one below.

Code: Select all

NSDictionary *tmp_d = [NSDictionary dictionary];
[smartFox sendXtMessage:@"timeEx" cmd:@"gst" paramObj:tmp_d type: @"xml" roomId:1];
This works without the server throwing errors but it don't return nothing!

Basically I just want to send a cmd to the extension and get a return value object. Developing with the smart fox server iphone API has been a bloody nightmare with virtually no support and half cooked doc's after paying big bucks for the Enterprise server.

Can some one please help us?

Posted: 22 Oct 2009, 09:47
by aw2xcd
Fix for the darn thing chopping off the first letter of the returned string

I still can't access the returned array.
The server code looks like this:

Code: Select all

var res = [];	// The list of params	
res[0] = "st";		
res[1] = "12345";//time to start game in miliseconds
_server.sendResponse(res, -1, null, [user], "str");
And on the iphone onExtensionResponse's evt only has the "st" and looses the second argument that should have the start time.

Posted: 22 Oct 2009, 22:14
by cemuzunlar
This will be fixed in the next release.

You can fix it by updating the function strReceived in INFSmartFoxiPhoneClient.m:

Code: Select all

- (void)strReceived:(NSString *)msg
{
    [self debugMessage:[NSString stringWithFormat:@"INFSmartFoxiPhoneClient:strReceived"]];
   
    // Got String response
    NSArray *params = [[msg substringWithRange:NSMakeRange(1, [msg length] - 2)] componentsSeparatedByString:_MSG_STR];
       
    NSString *handlerId = [params objectAtIndex:0];
    id<INFSmartFoxIMessageHandler> handler = [_messageHandlers objectForKey:handlerId];
   
    if (handler != nil) {
        [handler handleMessage:[params subarrayWithRange:NSMakeRange(1, [params count] - 1)] type:(NSString *)INFSMARTFOXCLIENT_XTMSG_TYPE_STR delegate:_delegate];
    }
    else {
        [self debugMessage:[NSString stringWithFormat:@"No handlers found for type:%@", handlerId]];
    }
}
Thanks