Not getting response back to client from custom operation

edited August 2013 in Native
SERVER: Photon Server v3, we are hosting
CLIENT: iOS, obj-c

We are having problems getting a response from a custom operation in the Photon Server LoadBalancing app using the obj-c iOS SDK.

We've added the code for the custom operation to AppLobby.cs and it works just fine for our tests. The debug message even show the correct data in the server log when called from the obj-c iOS SDK client we've created. The problem is that, as far as we can tell, the client's listener method onOperationResponse should be firing in response to the server's SendOperationResponse and it isn't.

Many of the client's listener methods do fire as expected, including the "return" methods such as connectReturn, disconnectReturn, createRoomReturn, etc. We even get the proper event listener methods firing when we enter/leave rooms and whatnot. But we never see onOperationResponse fire.

The order of operations for the obj-c iOS test client is:
1. Connect to the Master server :SUCCESSFUL -> connectReturn fires
2. Join Lobby :SUCCESSFUL -> joinLobbyReturn fires
3. Call custom op : FAIL -> onOperationRespose doesn't fire

Though as I said before, the server successfully receives and interprets the custom operation call and shows the correct data in the debug log, we just never seem to get anything back on the client. Anyone have suggestions on what we might be missing?

Code snippets provided below...

Server Code:

[code2=csharp]protected virtual void ExecuteOperation(MasterClientPeer peer, OperationRequest operationRequest, SendParameters sendParameters)
{
try
{
OperationResponse response;

switch ((OperationCode)operationRequest.OperationCode)
{

...

case OperationCode.OurCustomOp:
response = this.HandleOurCustomOp(peer, operationRequest, sendParameters);
break;

...

}

if (response != null)
{
peer.SendOperationResponse(response, sendParameters);
}

...

}
}

...

protected virtual OperationResponse HandleOurCustomOp(MasterClientPeer peer, OperationRequest operationRequest, SendParameters sendParameters)
{

...

if (log.IsDebugEnabled)
{
log.DebugFormat("HandleOurCustomOp: Returned: {0}, Actual: {1}", opResponse.OurData.Count, this.OurData.Count);
}

return new OperationResponse(operationRequest.OperationCode, opResponse);
}[/code2]



Client code:

[code2=objc]@interface OurClient : NSObject <EGLoadBalancingListener>
{
EGLoadBalancingClient* client;
}
@end

@implementation OurClient

-(id)initWithAppId:(NSString*)appId andAppVersion:(NSString*)appVersion andUserName:(NSString*)userName
{
client = [[EGLoadBalancingClient alloc] initClient:self :appId :appVersion :userName :NO];
...
}

...

- (void) onOperationResponse:(EGOperationResponse*)operationResponse
{
[self echo:[NSString stringWithFormat:@onOperationResponse [%d] %@", operationResponse.ReturnCode, operationResponse.description]];
}

-(bool)callCustomOp
{
NSNumber* CUSTOMOP_CODE1 = [NSNumber numberWithInt:100];
NSNumber* CUSTOMOP_VALUE1 = [NSNumber numberWithBool:YES];

NSNumber* CUSTOMOP_CODE2 = [NSNumber numberWithInt:101];
NSString* CUSTOMOP_VALUE2 = @MyUsername

NSDictionary* OPPARAMS = [NSDictionary dictionaryWithObjectsAndKeys:
CUSTOMOP_VALUE1, CUSTOMOP_CODE1,
CUSTOMOP_VALUE2, CUSTOMOP_CODE2,
nil];

EGOperationRequest* opReq = [[EGOperationRequest alloc] initWithOperationCode:OpCodes.OurCustomOpCode :OPPARAMS];

return [client opCustom:opReq :YES];
}

@end[/code2]

Comments

  • Hi randall.

    The client side LoadBalancing layer currently does not route responses for custom ops to it's listener. The listener doesn't even offer a onOperationResponse()-method.

    When you want to use custom ops, then you should subclass EGLoadBalancingClient to add code that handles your custom ops.

    [code2=objc]@interface ExtendedLoadBalancingClient : EGLoadBalancingClient
    @end[/code2]

    [code2=objc]@implementation ExtendedLoadBalancingClient

    - (void) onOperationResponse:(EGOperationResponse*)operationResponse
    {
    [super onOperationResponse:operationResponse]; // important - without this call to the baseclass implementation our override would break most of the existing functionality of EGLoadBalancingClient
    switch(operationResponse.OperationCode)
    {
    case OurCustomOpsOpCode:
    // add your custom op specific code here
    break;
    default:
    break;
    }
    }
    @end[/code2]

    [code2=objc]@interface OurClient : NSObject <EGLoadBalancingListener>
    {
    ExtendedLoadBalancingClient* client;
    }
    @end[/code2]

    [code2=objc]-(id)initWithAppId:(NSString*)appId andAppVersion:(NSString*)appVersion andUserName:(NSString*)userName
    {
    client = [[ExtendendedLoadBalancingClient alloc] initClient:self :appId :appVersion :userName :NO];
    ...
    }[/code2]
Sign In or Register to comment.