Understand onObjectMessage on ios
Posted: 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.
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.
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
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;---[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