Why no PhotonClient.SendOperationRequest(OperationRequest) ?
Options
Hey
TcpClient has a nice .SendOperationRequest(OperationRequest request) method
and I wondered why PhotonPeer doesn't have such a method?
The benefit would be to be able to send a (derived) OperationRequest and validate it on the server side with the same code like you can do it with the TcpClient.
Even better I could put this OperationRequest in a Common.dll lib used by client and server side.
Using a PhotonPeer.SendOperationRequest( loginRequest, true, 0, true )
would be less error-prone than duplicating some code logic like this:
Client side:
You see what I mean?
TcpClient has a nice .SendOperationRequest(OperationRequest request) method
and I wondered why PhotonPeer doesn't have such a method?
The benefit would be to be able to send a (derived) OperationRequest and validate it on the server side with the same code like you can do it with the TcpClient.
Even better I could put this OperationRequest in a Common.dll lib used by client and server side.
Using a PhotonPeer.SendOperationRequest( loginRequest, true, 0, true )
would be less error-prone than duplicating some code logic like this:
Client side:
public static class LoginOperations { public static void Login(PhotonPeer game, string username, string password) { Dictionary<byte, object> table = new Dictionary<byte, object>() { {(byte) ParameterCode.Username, username }, {(byte) ParameterCode.Password, password } }; game.OpCustom((byte)OperationCode.Login, table, true, 0, true); } }Server side:
public class LoginRequest : Operation { public LoginRequest( IRpcProtocol protocol, OperationRequest request) : base(protocol, request) {} [DataMember(Code = (byte)ParameterCode.Username, IsOptional = false)] public string Username { get; set; } [DataMember(Code = (byte)ParameterCode.Password, IsOptional = false)] public string Password { get; set; } } [Operation(OperationCode = (byte)OperationCode.Login)] public OperationResponse HandleLogin(PeerBase peer, OperationRequest operationRequest) { var request = new LoginRequest(peer.Protocol, operationRequest); if (!request.IsValid) { Log.Info(" ** Login failed for : LATER log details "); return new OperationResponse(); } etc }
You see what I mean?
0
Comments
-
PhotonPeer has 2 OpCustom methods, one of them should accept an OperationRequest parameter.
I don't know if the method alone is of any help here since you still need the Operation subclass for contract validation. Server-to-server peers allow the operation contracts on both sides which saves a lot of work. So what you really need are the contract classes on the client. We _might_ add this later - if we find the time.0 -
Yeh - I was hoping for this Operation : DataContract version.
Because for now client and server are using different OperationRequests.
On the client-side Peer.OpCustom( ExitGames.Client.Photon.OperationRequest, bool sendReliable, byte channelId, bool encrypt);
And not from Photon.SocketServer.OperationRequest like the TcpClient.SendOperationRequest()
So I don't see how to use the same "OperationRequest" on the PhotonClient and for validation on the server side.
I can wait for RC50