Cust Authentication Server-Side Code
Options
I've successfully implemented Photon's Custom Authentication and I'm now trying to set the UserId value when the player logs in. Unfortunately, I have no idea where to start. It seems like the documentation is either out-of-date or non-existent.
What is the correct response the server should send back in order to set the UserId? Here is what I have tried (with no success):
What is the correct response the server should send back in order to set the UserId? Here is what I have tried (with no success):
{'ResultCode': 1, 'Data': {'UserId': 1}} {'ResultCode': 1, UserId': 1}Also, if there is documentation on this could someone please point me in the right direction? Thanks!
0
Comments
-
EDIT:
{'ResultCode': 1, 'Data': {'UserId': 1}} {'ResultCode': 1, 'UserId': 1}
0 -
Hi @Diadem,
It seems like you know what you're doing. The correct response should be{'ResultCode': 1, 'UserId': <userId>}
.
Unfortunately the feature that makes setting UserId after receiving custom authentication response possible was only introduced in LoadBalancing SDK v4.0.0.10 and it will be available in PUN v1.61.
If you want to do it manually, all you need is to set the local UserId to the value of the parameter (ParameterCode.UserId = 225
) received in the custom authentication response (OperationCode.Authenticate = 230
).1 -
@Diadem,
try adding these lines :if (operationResponse.Parameters.ContainsKey(ParameterCode.UserId)) { //DebugReturn(DebugLevel.ERROR, operationResponse.ToStringFull()); this.CustomAuthenticationValues.UserId = operationResponse.Parameters[ParameterCode.UserId] as string; }
inNetworkingPeer.OnOperationResponse()
whenoperationResponse.OperationCode == OperationCode.Authenticate
.1 -
No,Diadem said:Hey @JohnTube - does this work for PUN? I'm not finding any documentation on NetworkingPeer for PUN.
I'm going to try OnWebRpcResponse to see if that worksOnWebRpcResponse
does not have anything to do with this. It is the callback of WebRPC operations only.
Go to "NetworkingPeer.cs" file in your project and findOnOperationResponse
then update it :void OnOperationResponse(OperationResponse operationResponse){ switch(operationResponse.Operation){ case OperationCode.Authenticate : if (operationResponse.Parameters.ContainsKey(ParameterCode.UserId)) { this.CustomAuthenticationValues.UserId = operationResponse.Parameters[ParameterCode.UserId] as string; } break; } }
1