Returning null in an operation handler
Options
So I've created a new operation in the MMO server demo called SwitchWorld. This operation basically needs to do the following (in order):
For step #2, I see that in some cases "return null;" is used in an operation handler, which based off of what I can tell, tells Photon to place that operation request back in its queue (at the back) so it can be handled again later. Is this correct?
I'm also curious how you guys would implement a SwitchWorld operation in your MMO server demo.
Thanks in advance.
- Change the operation handler to MmoPeer.
- The current SwitchWorld operation request needs to be re-sent to that new operation handler (without sending a response yet)
- The SwitchWorld operation handler in MmoPeer needs to delete the current actor from his current world, delete the actor, and recreate the actor and put him in the newly requested world.
For step #2, I see that in some cases "return null;" is used in an operation handler, which based off of what I can tell, tells Photon to place that operation request back in its queue (at the back) so it can be handled again later. Is this correct?
I'm also curious how you guys would implement a SwitchWorld operation in your MMO server demo.
Thanks in advance.
0
Comments
-
if you returned an OperationResponse instance the OperationQueue would send the response to the client. Returning null won't send anything, that's all.
I would implement the SwitchWorld in MmoActor: Kill the current one and replace the current operation handler with a new MmoActor.0 -
Boris wrote:if you returned an OperationResponse instance the OperationQueue would send the response to the client. Returning null won't send anything, that's all.
I would implement the SwitchWorld in MmoActor: Kill the current one and replace the current operation handler with a new MmoActor.while( world.ItemCache.AddItem( avatar ) == false ) { Item otherAvatarItem; if( world.ItemCache.TryGetItem( avatar.Type, avatar.Id, out otherAvatarItem ) ) { avatar.Dispose(); actor.Dispose(); interestArea.Dispose(); ((MmoItem)otherAvatarItem).Owner.Peer.DisconnectByOtherPeer( this.peer, request ); // request continued later, no response here return null; } }
I notice that if the player is still in the world, the EnterWorld handler is continuously called, which is why I thought returning NULL means re-queuing that operation. I had a bug where the DisconnectByOtherPeer was not removing the actor from the world, and EnterWorld would continue to be executed until it was completely removed.
How was this happening?0 -
this line will enqueue the request again
((MmoItem)otherAvatarItem).Owner.Peer.DisconnectByOtherPeer( this.peer, request );
0