We are trying to manage rooms' creation and join from photon server side without letting choose to the client for one of those operations explicitly. I know that's not the conventional way to use photon but we are doing some experiments.
In this case client asks for a room with our custom operation code. We intercept on server side the request in the ExecuteOperation of AppLobby, then we check for a matched peer in our match making system. If the matched peer doesn't exist then the current peer is saved in a waiting peers list. While if the matched peer is returned then we create the room with an ad-hoc operation request passed to the HandleCreateGame of AppLobby for a response. It usually works and the peer auto-joins the room too, changing its ClientState into Joined from client side. Then on server side we intercept the Update of the GameState in OnGameStateChanged of AppLobby and there we try to make join the matched peer.
The JoinGame response has return code 0 and it seems to work but that matched peer from client side gets the error "Create failed on GameServer. Changing back to MasterServer. ReturnCode: -2" in GameEnteredOnGameServer of LoadBalancingClient and the StringFull of the operation response results to be "OperationResponse 227: ReturnCode: -2 (Missing value 255 (JoinGameRequest.GameId)
). Parameters: {}".
So we don't understand who sent this quite strange response, because it refers to an operation code of creation (227) with operation invalid error code (-2) and a debug message which warns us about a GameId (255) missing value read from a JoinGameRequest.GameId.....what? The request was join but the operation code was creation?
What could be the issue? Or what can you suggest me to identify where this response is made and sent?
Here's some code snippets.
In ExecuteOperation of AppLobby:
...
...
...
switch (operationRequest.OperationCode)
{
case (byte)STB.Common.CommunicationCodes.STBOperationCode.JoinOrCreateRoom:
MasterClientPeer matchPeer;
if (CheckMatchMaking(peer, out matchPeer))
{
//create autojoin peer
response = this.HandleCreateGame(peer, new OperationRequest((byte)OperationCode.CreateGame, null));
string sRoomName = response[(byte)ParameterCode.GameId] as string;
dictMatchPeers.Add(sRoomName, matchPeer);
}
break;
...
...
...
In OnGameStateChanged of AppLobby:
...
...
...
protected virtual void OnGameStateChanged(GameState gameState)
{
MasterClientPeer matchPeer;
if (dictMatchPeers.TryGetValue(gameState.Id, out matchPeer))
{
//join match peer
Dictionary dictParams = new Dictionary();
dictParams.Add((byte)ParameterCode.GameId, gameState.Id);
OperationResponse matchPeerResponse = this.HandleJoinGame(matchPeer, new OperationRequest((byte)OperationCode.JoinGame, dictParams));
log.Error("AppLobby OnGameStateChanged code " + matchPeerResponse.OperationCode + " peer " + matchPeer.UserId);
matchPeer.SendOperationResponse(matchPeerResponse, new SendParameters());
}
}
...
...
...
In this case client asks for a room with our custom operation code. We intercept on server side the request in the ExecuteOperation of AppLobby, then we check for a matched peer in our match making system. If the matched peer doesn't exist then the current peer is saved in a waiting peers list. While if the matched peer is returned then we create the room with an ad-hoc operation request passed to the HandleCreateGame of AppLobby for a response. It usually works and the peer auto-joins the room too, changing its ClientState into Joined from client side. Then on server side we intercept the Update of the GameState in OnGameStateChanged of AppLobby and there we try to make join the matched peer.
The JoinGame response has return code 0 and it seems to work but that matched peer from client side gets the error "Create failed on GameServer. Changing back to MasterServer. ReturnCode: -2" in GameEnteredOnGameServer of LoadBalancingClient and the StringFull of the operation response results to be "OperationResponse 227: ReturnCode: -2 (Missing value 255 (JoinGameRequest.GameId)
). Parameters: {}".
So we don't understand who sent this quite strange response, because it refers to an operation code of creation (227) with operation invalid error code (-2) and a debug message which warns us about a GameId (255) missing value read from a JoinGameRequest.GameId.....what? The request was join but the operation code was creation?
What could be the issue? Or what can you suggest me to identify where this response is made and sent?
Here's some code snippets.
In ExecuteOperation of AppLobby:
...
...
...
switch (operationRequest.OperationCode)
{
case (byte)STB.Common.CommunicationCodes.STBOperationCode.JoinOrCreateRoom:
MasterClientPeer matchPeer;
if (CheckMatchMaking(peer, out matchPeer))
{
//create autojoin peer
response = this.HandleCreateGame(peer, new OperationRequest((byte)OperationCode.CreateGame, null));
string sRoomName = response[(byte)ParameterCode.GameId] as string;
dictMatchPeers.Add(sRoomName, matchPeer);
}
break;
...
...
...
In OnGameStateChanged of AppLobby:
...
...
...
protected virtual void OnGameStateChanged(GameState gameState)
{
MasterClientPeer matchPeer;
if (dictMatchPeers.TryGetValue(gameState.Id, out matchPeer))
{
//join match peer
Dictionary dictParams = new Dictionary();
dictParams.Add((byte)ParameterCode.GameId, gameState.Id);
OperationResponse matchPeerResponse = this.HandleJoinGame(matchPeer, new OperationRequest((byte)OperationCode.JoinGame, dictParams));
log.Error("AppLobby OnGameStateChanged code " + matchPeerResponse.OperationCode + " peer " + matchPeer.UserId);
matchPeer.SendOperationResponse(matchPeerResponse, new SendParameters());
}
}
...
...
...