本文整理汇总了C#中OperationResponse.ToStringFull方法的典型用法代码示例。如果您正苦于以下问题:C# OperationResponse.ToStringFull方法的具体用法?C# OperationResponse.ToStringFull怎么用?C# OperationResponse.ToStringFull使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OperationResponse
的用法示例。
在下文中一共展示了OperationResponse.ToStringFull方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnOperationResponse
public override void OnOperationResponse(OperationResponse operationResponse)
{
base.OnOperationResponse(operationResponse);
switch (operationResponse.OperationCode)
{
case (byte)OperationCode.Authenticate:
if (operationResponse.ReturnCode == ErrorCode.InvalidAuthentication)
{
this.ErrorMessageToShow = string.Format("Authentication failed. Your AppId: {0}.\nMake sure to set the AppId in DemoGUI.cs by replacing \"<insert your app id here>\".\nResponse: {1}", this.AppId, operationResponse.ToStringFull());
this.DebugReturn(DebugLevel.ERROR, this.ErrorMessageToShow);
}
if (operationResponse.ReturnCode == ErrorCode.InvalidOperation || operationResponse.ReturnCode == ErrorCode.InternalServerError)
{
this.ErrorMessageToShow = string.Format("Authentication failed. You successfully connected but the server ({0}) but it doesn't know the 'authenticate'. Check if it runs the Loadblancing server-logic.\nResponse: {1}", this.MasterServerAddress, operationResponse.ToStringFull());
this.DebugReturn(DebugLevel.ERROR, this.ErrorMessageToShow);
}
break;
case (byte)OperationCode.CreateGame:
string gsAddress = (string)operationResponse[ParameterCode.Address];
if (!string.IsNullOrEmpty(gsAddress) && gsAddress.StartsWith("127.0.0.1"))
{
this.ErrorMessageToShow = string.Format("The master forwarded you to a gameserver with address: {0}.\nThat address points to 'this computer' anywhere. This might be a configuration error in the game server.", gsAddress);
this.DebugReturn(DebugLevel.ERROR, this.ErrorMessageToShow);
}
break;
case (byte)OperationCode.JoinRandomGame:
string gsAddressJoin = (string)operationResponse[ParameterCode.Address];
if (!string.IsNullOrEmpty(gsAddressJoin) && gsAddressJoin.StartsWith("127.0.0.1"))
{
this.ErrorMessageToShow = string.Format("The master forwarded you to a gameserver with address: {0}.\nThat address points to 'this computer' anywhere. This might be a configuration error in the game server.", gsAddressJoin);
this.DebugReturn(DebugLevel.ERROR, this.ErrorMessageToShow);
}
if (operationResponse.ReturnCode != 0)
{
this.OpCreateRoom(null, new RoomOptions() { MaxPlayers = 2 }, null);
}
break;
case (byte) SPShared.Operations.SPOperationCode.UpdateFlightControls:
Debug.Log ("Got Update response!");
break;
}
}
示例2: OnOperationResponse
public void OnOperationResponse(OperationResponse operationResponse)
{
if (PhotonNetwork.networkingPeer.State == global::PeerState.Disconnecting)
{
if (PhotonNetwork.logLevel >= PhotonLogLevel.Informational)
{
Debug.Log("OperationResponse ignored while disconnecting. Code: " + operationResponse.OperationCode);
}
return;
}
// extra logging for error debugging (helping developers with a bit of automated analysis)
if (operationResponse.ReturnCode == 0)
{
if (PhotonNetwork.logLevel >= PhotonLogLevel.Informational)
Debug.Log(operationResponse.ToString());
}
else
{
if (operationResponse.ReturnCode == ErrorCode.OperationNotAllowedInCurrentState)
{
Debug.LogError("Operation " + operationResponse.OperationCode + " could not be executed (yet). Wait for state JoinedLobby or ConnectedToMaster and their callbacks before calling operations. WebRPCs need a server-side configuration. Enum OperationCode helps identify the operation.");
}
else if (operationResponse.ReturnCode == ErrorCode.WebHookCallFailed)
{
Debug.LogError("Operation " + operationResponse.OperationCode + " failed in a server-side plugin. Check the configuration in the Dashboard. Message from server-plugin: " + operationResponse.DebugMessage);
}
else if (PhotonNetwork.logLevel >= PhotonLogLevel.Informational)
{
Debug.LogError("Operation failed: " + operationResponse.ToStringFull() + " Server: " + this.server);
}
}
// use the "secret" or "token" whenever we get it. doesn't really matter if it's in AuthResponse.
if (operationResponse.Parameters.ContainsKey(ParameterCode.Secret))
{
if (this.CustomAuthenticationValues == null)
{
this.CustomAuthenticationValues = new AuthenticationValues();
// this.DebugReturn(DebugLevel.ERROR, "Server returned secret. Created CustomAuthenticationValues.");
}
this.CustomAuthenticationValues.Secret = operationResponse[ParameterCode.Secret] as string;
}
switch (operationResponse.OperationCode)
{
case OperationCode.Authenticate:
{
// PeerState oldState = this.State;
if (operationResponse.ReturnCode != 0)
{
if (operationResponse.ReturnCode == ErrorCode.InvalidOperationCode)
{
Debug.LogError(string.Format("If you host Photon yourself, make sure to start the 'Instance LoadBalancing' "+ this.ServerAddress));
}
else if (operationResponse.ReturnCode == ErrorCode.InvalidAuthentication)
{
Debug.LogError(string.Format("The appId this client sent is unknown on the server (Cloud). Check settings. If using the Cloud, check account."));
SendMonoMessage(PhotonNetworkingMessage.OnFailedToConnectToPhoton, DisconnectCause.InvalidAuthentication);
}
else if (operationResponse.ReturnCode == ErrorCode.CustomAuthenticationFailed)
{
Debug.LogError(string.Format("Custom Authentication failed (either due to user-input or configuration or AuthParameter string format). Calling: OnCustomAuthenticationFailed()"));
SendMonoMessage(PhotonNetworkingMessage.OnCustomAuthenticationFailed, operationResponse.DebugMessage);
}
else
{
Debug.LogError(string.Format("Authentication failed: '{0}' Code: {1}", operationResponse.DebugMessage, operationResponse.ReturnCode));
}
this.State = global::PeerState.Disconnecting;
this.Disconnect();
if (operationResponse.ReturnCode == ErrorCode.MaxCcuReached)
{
if (PhotonNetwork.logLevel >= PhotonLogLevel.Informational)
Debug.LogWarning(string.Format("Currently, the limit of users is reached for this title. Try again later. Disconnecting"));
SendMonoMessage(PhotonNetworkingMessage.OnPhotonMaxCccuReached);
SendMonoMessage(PhotonNetworkingMessage.OnConnectionFail, DisconnectCause.MaxCcuReached);
}
else if (operationResponse.ReturnCode == ErrorCode.InvalidRegion)
{
if (PhotonNetwork.logLevel >= PhotonLogLevel.Informational)
Debug.LogError(string.Format("The used master server address is not available with the subscription currently used. Got to Photon Cloud Dashboard or change URL. Disconnecting."));
SendMonoMessage(PhotonNetworkingMessage.OnConnectionFail, DisconnectCause.InvalidRegion);
}
else if (operationResponse.ReturnCode == ErrorCode.AuthenticationTicketExpired)
{
if (PhotonNetwork.logLevel >= PhotonLogLevel.Informational)
Debug.LogError(string.Format("The authentication ticket expired. You need to connect (and authenticate) again. Disconnecting."));
SendMonoMessage(PhotonNetworkingMessage.OnConnectionFail, DisconnectCause.AuthenticationTicketExpired);
}
break;
}
else
{
if (this.server == ServerConnection.NameServer)
{
//.........这里部分代码省略.........
示例3: HandleAuthResponse
private void HandleAuthResponse(OperationResponse operationResponse)
{
this.listener.DebugReturn(DebugLevel.INFO, operationResponse.ToStringFull() + " on: " + this.chatPeer.NameServerAddress);
if (operationResponse.ReturnCode == 0)
{
if (this.State == ChatState.ConnectedToNameServer)
{
this.State = ChatState.Authenticated;
this.listener.OnChatStateChange(this.State);
if (operationResponse.Parameters.ContainsKey(ParameterCode.Secret))
{
if (this.AuthValues == null)
{
this.AuthValues = new AuthenticationValues();
}
this.AuthValues.Token = operationResponse[ParameterCode.Secret] as string;
this.FrontendAddress = (string) operationResponse[ParameterCode.Address];
// we disconnect and status handler starts to connect to front end
this.chatPeer.Disconnect();
}
else
{
//TODO: error reaction!
}
}
else if (this.State == ChatState.ConnectingToFrontEnd)
{
this.msDeltaForServiceCalls = this.msDeltaForServiceCalls * 4; // when we arrived on chat server: limit Service calls some more
this.State = ChatState.ConnectedToFrontEnd;
this.listener.OnChatStateChange(this.State);
this.listener.OnConnected();
}
}
else
{
//this.listener.DebugReturn(DebugLevel.INFO, operationResponse.ToStringFull() + " NS: " + this.NameServerAddress + " FrontEnd: " + this.frontEndAddress);
switch (operationResponse.ReturnCode)
{
case ErrorCode.InvalidAuthentication:
this.DisconnectedCause = ChatDisconnectCause.InvalidAuthentication;
break;
case ErrorCode.CustomAuthenticationFailed:
this.DisconnectedCause = ChatDisconnectCause.CustomAuthenticationFailed;
break;
case ErrorCode.InvalidRegion:
this.DisconnectedCause = ChatDisconnectCause.InvalidRegion;
break;
case ErrorCode.MaxCcuReached:
this.DisconnectedCause = ChatDisconnectCause.MaxCcuReached;
break;
case ErrorCode.OperationNotAllowedInCurrentState:
this.DisconnectedCause = ChatDisconnectCause.OperationNotAllowedInCurrentState;
break;
}
this.State = ChatState.Disconnecting;
this.chatPeer.Disconnect();
}
}
示例4: OnOperationResponse
public void OnOperationResponse(OperationResponse operationResponse)
{
if (PhotonNetwork.networkingPeer.State == global::PeerState.Disconnecting)
{
if (this.DebugOut >= DebugLevel.INFO)
{
this.DebugReturn(DebugLevel.INFO, "OperationResponse ignored while disconnecting: " + operationResponse.OperationCode);
}
return;
}
// extra logging for error debugging (helping developers with a bit of automated analysis)
if (operationResponse.ReturnCode == 0)
{
if (this.DebugOut >= DebugLevel.INFO)
{
this.DebugReturn(DebugLevel.INFO, operationResponse.ToString());
}
}
else
{
if (this.DebugOut >= DebugLevel.WARNING)
{
if (operationResponse.ReturnCode == ErrorCode.OperationNotAllowedInCurrentState)
{
this.DebugReturn(DebugLevel.WARNING, "Operation could not be executed yet. Wait for state JoinedLobby or ConnectedToMaster and their respective callbacks before calling OPs. Client must be authorized.");
}
this.DebugReturn(DebugLevel.WARNING, operationResponse.ToStringFull());
}
}
switch (operationResponse.OperationCode)
{
case OperationCode.Authenticate:
{
// PeerState oldState = this.State;
if (operationResponse.ReturnCode != 0)
{
if (operationResponse.ReturnCode == ErrorCode.InvalidOperationCode)
{
this.DebugReturn(DebugLevel.ERROR, string.Format("If you host Photon yourself, make sure to start the 'Instance LoadBalancing'"));
}
else if (operationResponse.ReturnCode == ErrorCode.InvalidAuthentication)
{
this.DebugReturn(DebugLevel.ERROR, string.Format("The appId this client sent is unknown on the server (Cloud). Check settings. If using the Cloud, check account."));
}
else if (operationResponse.ReturnCode == ErrorCode.CustomAuthenticationFailed)
{
this.DebugReturn(DebugLevel.ERROR, string.Format("Custom Authentication failed (either due to user-input or configuration or AuthParameter string format). Calling: OnCustomAuthenticationFailed()"));
SendMonoMessage(PhotonNetworkingMessage.OnCustomAuthenticationFailed, operationResponse.DebugMessage);
}
else if (this.DebugOut >= DebugLevel.ERROR)
{
this.DebugReturn(DebugLevel.ERROR, string.Format("Authentication failed: '{0}' Code: {1}", operationResponse.DebugMessage, operationResponse.ReturnCode));
}
this.Disconnect();
this.State = global::PeerState.Disconnecting;
if (operationResponse.ReturnCode == ErrorCode.MaxCcuReached)
{
this.DebugReturn(DebugLevel.ERROR, string.Format("Currently, the limit of users is reached for this title. Try again later. Disconnecting"));
SendMonoMessage(PhotonNetworkingMessage.OnPhotonMaxCccuReached);
SendMonoMessage(PhotonNetworkingMessage.OnConnectionFail, DisconnectCause.MaxCcuReached);
}
else if (operationResponse.ReturnCode == ErrorCode.InvalidRegion)
{
this.DebugReturn(DebugLevel.ERROR, string.Format("The used master server address is not available with the subscription currently used. Got to Photon Cloud Dashboard or change URL. Disconnecting"));
SendMonoMessage(PhotonNetworkingMessage.OnConnectionFail, DisconnectCause.InvalidRegion);
}
break;
}
else
{
if (this.State == global::PeerState.Connected || this.State == global::PeerState.ConnectedComingFromGameserver)
{
if (operationResponse.Parameters.ContainsKey(ParameterCode.Secret))
{
if (this.AuthValues != null)
{
this.AuthValues.Secret = operationResponse[ParameterCode.Secret] as string;
}
else
{
if (this.DebugOut >= DebugLevel.WARNING)
{
this.DebugReturn(DebugLevel.WARNING, "Server returned secret but AuthValues are null. Won't use this.");
}
}
}
if (PhotonNetwork.autoJoinLobby)
{
this.OpJoinLobby();
this.State = global::PeerState.Authenticated;
}
//.........这里部分代码省略.........
示例5: OnOperationResponse
public override void OnOperationResponse(OperationResponse operationResponse)
{
base.OnOperationResponse(operationResponse); // important to call, to keep state up to date
if (operationResponse.ReturnCode != ErrorCode.Ok)
{
this.DebugReturn(DebugLevel.ERROR, operationResponse.ToStringFull() + " " + this.State);
}
logger.Append(String.Format("---OperationResponse:"));
logger.Append(String.Format(" |Code: {0}", OperationCodeLookup.NameOf[operationResponse.OperationCode]));
logger.Append(String.Format(" |ReturnCode: {0}", operationResponse.ReturnCode));
switch (operationResponse.OperationCode)
{
case OperationCode.Authenticate:
break;
case OperationCode.JoinLobby:
break;
case OperationCode.JoinRandomGame:
break;
case OperationCode.JoinGame:
case OperationCode.CreateGame:
if (this.State == ClientState.Joined)
{
this.cache.ActorNr = (int)operationResponse.Parameters[ParameterCode.ActorNr];
}
break;
case OperationCode.GetProperties:
logger.Append(operationResponse.ToStringFull());
break;
case OperationCode.SetProperties:
//logger.Append(operationResponse.ToStringFull());
opResponseHandler.OnSetPropertiesResponse();
break;
case OperationCode.RaiseEvent:
break;
case OperationCode.Rpc:
WebRpcResponse webResponse = new WebRpcResponse(operationResponse);
if (operationResponse.ReturnCode != 0)
{
DebugReturn(DebugLevel.ERROR, "WebRpc failed. Response: " + operationResponse.ToStringFull());
DebugReturn(DebugLevel.ERROR, "WebRpc '" + webResponse.Name + "' failed. Error: " + webResponse.ReturnCode + " Message: " + webResponse.DebugMessage);
}
else
{
webrpcHandler.OnWebRpcResponse(webResponse);
}
break;
}
logger.Flush();
}
示例6: OnOperationResponse
public void OnOperationResponse(OperationResponse operationResponse)
{
if (PhotonNetwork.networkingPeer.State == global::PeerState.Disconnecting)
{
if (this.DebugOut >= DebugLevel.INFO)
{
this.DebugReturn(DebugLevel.INFO, "OperationResponse ignored while disconnecting: " + operationResponse.OperationCode);
}
return;
}
// extra logging for error debugging (helping developers with a bit of automated analysis)
if (operationResponse.ReturnCode == 0)
{
if (this.DebugOut >= DebugLevel.INFO)
{
this.DebugReturn(DebugLevel.INFO, operationResponse.ToString());
}
}
else
{
if (this.DebugOut >= DebugLevel.WARNING)
{
if (operationResponse.ReturnCode == ErrorCode.OperationNotAllowedInCurrentState)
{
this.DebugReturn(DebugLevel.WARNING, "Operation could not be executed yet. Wait for state JoinedLobby or ConnectedToMaster and their respective callbacks before calling OPs. Client must be authorized.");
}
this.DebugReturn(DebugLevel.WARNING, operationResponse.ToStringFull());
}
}
switch (operationResponse.OperationCode)
{
case OperationCode.Authenticate:
{
// PeerState oldState = this.State;
if (operationResponse.ReturnCode != 0)
{
if (this.DebugOut >= DebugLevel.ERROR)
{
this.DebugReturn(DebugLevel.ERROR, string.Format("Authentication failed: '{0}' Code: {1}", operationResponse.DebugMessage, operationResponse.ReturnCode));
}
if (operationResponse.ReturnCode == ErrorCode.InvalidOperationCode)
{
this.DebugReturn(DebugLevel.ERROR, string.Format("If you host Photon yourself, make sure to start the 'Instance LoadBalancing'"));
}
if (operationResponse.ReturnCode == ErrorCode.InvalidAuthentication)
{
this.DebugReturn(DebugLevel.ERROR, string.Format("The appId this client sent is unknown on the server (Cloud). Check settings. If using the Cloud, check account."));
}
this.Disconnect();
this.State = global::PeerState.Disconnecting;
if (operationResponse.ReturnCode == ErrorCode.MaxCcuReached)
{
this.DebugReturn(DebugLevel.ERROR, string.Format("Currently, the limit of users is reached for this title. Try again later. Disconnecting"));
SendMonoMessage(PhotonNetworkingMessage.OnPhotonMaxCccuReached);
}
break;
}
else
{
if (this.State == global::PeerState.Connected || this.State == global::PeerState.ConnectedComingFromGameserver)
{
if (operationResponse.Parameters.ContainsKey(ParameterCode.Position))
{
this.mQueuePosition = (int)operationResponse[ParameterCode.Position];
// returnValues for Authenticate always include this value!
if (this.mQueuePosition > 0)
{
// should only happen, if just out of nowhere the
// amount of players going online at the same time
// is increasing faster, than automatically started
// additional gameservers could have been booten up
if (this.State == global::PeerState.ConnectedComingFromGameserver)
{
this.State = global::PeerState.QueuedComingFromGameserver;
}
else
{
this.State = global::PeerState.Queued;
}
// we break here (not joining the lobby, etc) as this client is queued
// the EventCode.QueueState will eventually resolve this state
break;
}
}
if (PhotonNetwork.autoJoinLobby)
{
this.OpJoinLobby();
this.State = global::PeerState.Authenticated;
}
else
//.........这里部分代码省略.........
示例7: OnOperationResponse
public override void OnOperationResponse(OperationResponse operationResponse)
{
base.OnOperationResponse(operationResponse);
// this.DebugReturn(DebugLevel.ERROR, operationResponse.ToStringFull()); // log as ERROR to make sure it's not filtered out due to log level
Debug.Log("[DemoGame] OnOperationResponse: {" + operationResponse.OperationCode + "} <" + operationResponse.ReturnCode + "> >>> " + operationResponse.ToString ());
switch (operationResponse.OperationCode)
{
case (byte)OperationCode.WebRpc:
Debug.Log("WebRpc-Response: " + operationResponse.ToStringFull());
if (operationResponse.ReturnCode == 0)
{
this.OnWebRpcResponse(new WebRpcResponse(operationResponse));
}
break;
case (byte)OperationCode.JoinGame:
case (byte)OperationCode.CreateGame:
if (this.Server == ServerConnection.GameServer)
{
if (operationResponse.ReturnCode == 0)
{
this.UpdateBoard();
}
}
break;
case (byte)OperationCode.JoinRandomGame:
if (operationResponse.ReturnCode == ErrorCode.NoRandomMatchFound)
{
// no room found: we create one!
this.CreateTurnbasedRoom();
}
break;
}
}
示例8: OnOperationResponse
public override void OnOperationResponse(OperationResponse operationResponse)
{
base.OnOperationResponse(operationResponse); // important to call, to keep state up to date
if (operationResponse.ReturnCode != ErrorCode.Ok)
{
this.DebugReturn(DebugLevel.ERROR, operationResponse.ToStringFull() + " " + this.State);
}
switch (operationResponse.OperationCode)
{
case OperationCode.Authenticate:
break;
case OperationCode.JoinRandomGame:
break;
case OperationCode.JoinGame:
case OperationCode.CreateGame:
if (this.State == ClientState.Joined)
{
this.actorNr = (int)operationResponse.Parameters[ParameterCode.ActorNr];
}
break;
case OperationCode.Rpc:
if (operationResponse.ReturnCode != 0)
{
DebugReturn(DebugLevel.ERROR, "WebRpc failed. Response: " + operationResponse.ToStringFull());
}
else
{
WebRpcResponse webResponse = new WebRpcResponse(operationResponse);
this.OnWebRpcResponse(webResponse);
}
break;
}
}
示例9: OnOperationResponse
/// <summary>
/// Uses the OperationResponses provided by the server to advance the internal state and call ops as needed.
/// </summary>
/// <remarks>
/// When this method finishes, it will call your OnOpResponseAction (if any). This way, you can get any
/// operation response without overriding this class.
///
/// To implement a more complex game/app logic, you should implement your own class that inherits the
/// LoadBalancingClient. Override this method to use your own operation-responses easily.
///
/// This method is essential to update the internal state of a LoadBalancingClient, so overriding methods
/// must call base.OnOperationResponse().
/// </remarks>
/// <param name="operationResponse">Contains the server's response for an operation called by this peer.</param>
public virtual void OnOperationResponse(OperationResponse operationResponse)
{
// if (operationResponse.ReturnCode != 0) this.DebugReturn(DebugLevel.ERROR, operationResponse.ToStringFull());
// use the "secret" or "token" whenever we get it. doesn't really matter if it's in AuthResponse.
if (operationResponse.Parameters.ContainsKey(ParameterCode.Secret))
{
if (this.AuthValues == null)
{
this.AuthValues = new AuthenticationValues();
//this.DebugReturn(DebugLevel.ERROR, "Server returned secret. Created AuthValues.");
}
this.AuthValues.Token = operationResponse[ParameterCode.Secret] as string;
}
switch (operationResponse.OperationCode)
{
case OperationCode.FindFriends:
if (operationResponse.ReturnCode != 0)
{
this.DebugReturn(DebugLevel.ERROR, "OpFindFriends failed: " + operationResponse.ToStringFull());
this.isFetchingFriendList = false;
break;
}
bool[] onlineList = operationResponse[ParameterCode.FindFriendsResponseOnlineList] as bool[];
string[] roomList = operationResponse[ParameterCode.FindFriendsResponseRoomIdList] as string[];
this.FriendList = new List<FriendInfo>(this.friendListRequested.Length);
for (int index = 0; index < this.friendListRequested.Length; index++)
{
FriendInfo friend = new FriendInfo();
friend.Name = this.friendListRequested[index];
friend.Room = roomList[index];
friend.IsOnline = onlineList[index];
this.FriendList.Insert(index, friend);
}
this.friendListRequested = null;
this.isFetchingFriendList = false;
this.friendListTimestamp = Environment.TickCount;
if (this.friendListTimestamp == 0)
{
this.friendListTimestamp = 1; // makes sure the timestamp is not accidentally 0
}
break;
case OperationCode.Authenticate:
{
if (operationResponse.ReturnCode != 0)
{
this.DebugReturn(DebugLevel.ERROR, operationResponse.ToStringFull() + " Server: " + this.Server + " Address: " + this.loadBalancingPeer.ServerAddress);
switch (operationResponse.ReturnCode)
{
case ErrorCode.InvalidAuthentication:
this.DisconnectedCause = DisconnectCause.InvalidAuthentication;
break;
case ErrorCode.CustomAuthenticationFailed:
this.DisconnectedCause = DisconnectCause.CustomAuthenticationFailed;
break;
case ErrorCode.InvalidRegion:
this.DisconnectedCause = DisconnectCause.InvalidRegion;
break;
case ErrorCode.MaxCcuReached:
this.DisconnectedCause = DisconnectCause.MaxCcuReached;
break;
case ErrorCode.OperationNotAllowedInCurrentState:
this.DisconnectedCause = DisconnectCause.OperationNotAllowedInCurrentState;
break;
}
this.State = ClientState.Disconnecting;
this.Disconnect();
break; // if auth didn't succeed, we disconnect (above) and exit this operation's handling
}
if (this.Server == ServerConnection.NameServer || this.Server == ServerConnection.MasterServer)
{
if (operationResponse.Parameters.ContainsKey(ParameterCode.UserId))
{
this.UserId = (string)operationResponse.Parameters[ParameterCode.UserId];
this.DebugReturn(DebugLevel.INFO, string.Format("Setting UserId sent by Server:{0}", this.UserId));
}
if (operationResponse.Parameters.ContainsKey((byte)233))
{
this.NickName = (string)operationResponse.Parameters[(byte)233];
//.........这里部分代码省略.........
示例10: OnOperationResponse
/// <summary>
/// Uses the operationResponse's provided by the server to advance the internal state and call ops as needed.
/// </summary>
/// <remarks>This method is essential to update the internal state of a LoadBalancingClient. Overriding methods must call base.OnOperationResponse.</remarks>
/// <param name="operationResponse">Contains the server's response for an operation called by this peer.</param>
public virtual void OnOperationResponse(OperationResponse operationResponse)
{
// if (operationResponse.ReturnCode != 0) this.DebugReturn(DebugLevel.ERROR, operationResponse.ToStringFull());
switch (operationResponse.OperationCode)
{
case OperationCode.Authenticate:
{
if (operationResponse.ReturnCode != 0)
{
switch (operationResponse.ReturnCode)
{
case ErrorCode.InvalidAuthentication:
this.DisconnectedCause = DisconnectCause.InvalidAuthentication;
break;
case ErrorCode.InvalidRegion:
this.DisconnectedCause = DisconnectCause.InvalidRegion;
break;
case ErrorCode.MaxCcuReached:
this.DisconnectedCause = DisconnectCause.MaxCcuReached;
break;
case ErrorCode.OperationNotAllowedInCurrentState:
this.DisconnectedCause = DisconnectCause.OperationNotAllowedInCurrentState;
break;
}
this.State = ClientState.Disconnecting;
this.Disconnect();
break; // if auth didn't succeed, we disconnect (above) and exit this operation's handling
}
if (this.State == ClientState.ConnectedToMaster)
{
this.State = ClientState.Authenticated;
if (this.AutoJoinLobby)
{
this.loadBalancingPeer.OpJoinLobby();
}
}
else if (this.State == ClientState.ConnectedToGameserver)
{
this.State = ClientState.Joining;
if (this.lastJoinType == JoinType.JoinRoom || this.lastJoinType == JoinType.JoinRandomRoom)
{
// if we just "join" the game, do so
this.OpJoinRoom(this.CurrentRoom.Name);
}
else if (this.lastJoinType == JoinType.CreateRoom)
{
this.OpCreateRoom(
this.CurrentRoom.Name,
this.CurrentRoom.IsVisible,
this.CurrentRoom.IsOpen,
this.CurrentRoom.MaxPlayers,
this.CurrentRoom.CustomProperties,
this.CurrentRoom.PropsListedInLobby);
}
break;
}
break;
}
case OperationCode.Leave:
this.CleanCachedValues();
break;
case OperationCode.JoinLobby:
this.State = ClientState.JoinedLobby;
break;
case OperationCode.JoinRandomGame: // this happens only on the master server. on gameserver this is a "regular" join
case OperationCode.CreateGame:
case OperationCode.JoinGame:
{
if (this.server == ServerConnection.GameServer)
{
this.GameEnteredOnGameServer(operationResponse);
}
else
{
if (operationResponse.ReturnCode == ErrorCode.NoRandomMatchFound)
{
// this happens only for JoinRandomRoom
// TODO: implement callback/reaction when no random game could be found (this is no bug and can simply happen if no games are open)
this.state = ClientState.JoinedLobby; // TODO: maybe we have to return to another state here (if we didn't join a lobby)
break;
}
// TODO: handle more error cases
if (operationResponse.ReturnCode != 0)
{
if (this.loadBalancingPeer.DebugOut >= DebugLevel.ERROR)
{
this.DebugReturn(DebugLevel.ERROR, string.Format("Getting into game failed, client stays on masterserver: {0}.", operationResponse.ToStringFull()));
}
//.........这里部分代码省略.........
示例11: OnOperationResponse
public override void OnOperationResponse(OperationResponse operationResponse)
{
base.OnOperationResponse(operationResponse);
switch (operationResponse.OperationCode) {
case (byte)OperationCode.WebRpc:
Debug.Log("WebRpc-Response: " + operationResponse.ToStringFull());
if (operationResponse.ReturnCode == 0) {
this.OnWebRpcResponse(new WebRpcResponse(operationResponse));
}
break;
case (byte)OperationCode.JoinLobby:
if (onJoinLobby != null) {
onJoinLobby(CurrentLobby);
}
break;
case (byte)OperationCode.JoinGame:
case (byte)OperationCode.CreateGame:
if (this.Server == ServerConnection.GameServer) {
if (operationResponse.ReturnCode == 0) {
if (onJoinRoom != null) {
onJoinRoom(CurrentRoom);
}
}
}
break;
case (byte)OperationCode.JoinRandomGame:
if (operationResponse.ReturnCode == ErrorCode.NoRandomMatchFound) {
// no room found: we create one!
if (onCreateRoom != null) {
onCreateRoom();
}
}
break;
}
}
示例12: OnOperationResponse
public void OnOperationResponse(OperationResponse operationResponse)
{
if (PhotonNetwork.networkingPeer.State == global::PeerState.Disconnecting)
{
if (this.DebugOut >= DebugLevel.INFO)
{
this.DebugReturn(DebugLevel.INFO, "OperationResponse ignored while disconnecting: " + operationResponse.OperationCode);
}
return;
}
if (operationResponse.ReturnCode == 0)
{
if (this.DebugOut >= DebugLevel.INFO)
{
this.DebugReturn(DebugLevel.INFO, operationResponse.ToString());
}
}
else
{
if (this.DebugOut >= DebugLevel.WARNING)
{
this.DebugReturn(DebugLevel.WARNING, operationResponse.ToStringFull());
}
}
switch (operationResponse.OperationCode)
{
case OperationCode.Authenticate:
{
// PeerState oldState = this.State;
if (operationResponse.ReturnCode != 0)
{
if (this.DebugOut >= DebugLevel.ERROR)
{
this.DebugReturn(DebugLevel.ERROR, string.Format("Authentication failed. Check AppId.\n{0}", operationResponse.ToStringFull()));
}
this.Disconnect();
this.State = global::PeerState.Disconnecting;
break;
}
else
{
if (this.State == global::PeerState.Connected
|| this.State == global::PeerState.ConnectedComingFromGameserver)
{
if (operationResponse.Parameters.ContainsKey(ParameterCode.Position))
{
this.mQueuePosition = (int)operationResponse[ParameterCode.Position];
// returnValues for Authenticate always include this value!
if (this.mQueuePosition > 0)
{
// should only happen, if just out of nowhere the
// amount of players going online at the same time
// is increasing faster, than automatically started
// additional gameservers could have been booten up
if (this.State == global::PeerState.ConnectedComingFromGameserver)
{
this.State = global::PeerState.QueuedComingFromGameserver;
}
else
{
this.State = global::PeerState.Queued;
}
// TODO TS: check how to react to being queued
// this.mListener.gotQueuedReturn();
break;
}
}
// Auto connect to LOBBY.
this.OpJoinLobby();
this.State = global::PeerState.Authenticated;
}
else if (this.State == global::PeerState.ConnectedToGameserver)
{
this.State = global::PeerState.Joining;
if (this.mLastJoinType == JoinType.JoinGame || this.mLastJoinType == JoinType.JoinRandomGame)
{
// if we just "join" the game, do so
this.OpJoin(this.mRoomToGetInto.name);
}
else if (this.mLastJoinType == JoinType.CreateGame)
{
this.OpCreateGame(
this.mRoomToGetInto.name,
this.mRoomToGetInto.visible,
this.mRoomToGetInto.open,
this.mRoomToGetInto.maxPlayers,
this.mRoomToGetInto.properties);
}
break;
}
}
break;
//.........这里部分代码省略.........
示例13: OnOperationResponse
// Traite un message de retour
public void OnOperationResponse(OperationResponse r)
{
Debug.WriteLine(r.ToStringFull());
this.response = r;
switch (r.OperationCode)
{
case 255:
Debug.WriteLine("Response received");
object pingStr;
r.Parameters.TryGetValue(100, out pingStr);
string str = (string)pingStr;
Console.WriteLine(str);
this.PingReceived.Invoke(this, EventArgs.Empty);
break;
case 254:
Debug.WriteLine("Response GetFullGame");
foreach (KeyValuePair<byte, object> author in r.Parameters)
{
Console.WriteLine("Key: {0}, Value: {1}", author.Key, author.Value.ToString());
}
this.FullGameReceived.Invoke(this, EventArgs.Empty);
object theGame;
r.Parameters.TryGetValue(100, out theGame);
byte[] byteGame = (byte[])theGame;
cStoredFullGame game;
game = this.ByteArrayToStructure(byteGame);
Console.WriteLine(game.Map1.mapCells[0].sPosX);
Console.WriteLine(game.Map1.mapCells[0].ePosX);
Console.WriteLine(game.Map1.mapCells[0].sPosY);
Console.WriteLine(game.Map1.mapCells[0].ePosY);
Console.WriteLine(game.Map1.mapCells[0].idBuilding);
Console.WriteLine(game.Map1.mapCells[0].levelBuilding);
break;
case 253:
Debug.WriteLine("Response SetFullGame");
break;
}
}
示例14: OnOperationResponse
/// <summary>
/// Uses the OperationResponses provided by the server to advance the internal state and call ops as needed.
/// </summary>
/// <remarks>
/// When this method finishes, it will call your OnOpResponseAction (if any). This way, you can get any
/// operation response without overriding this class.
///
/// To implement a more complex game/app logic, you should implement your own class that inherits the
/// LoadBalancingClient. Override this method to use your own operation-responses easily.
///
/// This method is essential to update the internal state of a LoadBalancingClient, so overriding methods
/// must call base.OnOperationResponse().
/// </remarks>
/// <param name="operationResponse">Contains the server's response for an operation called by this peer.</param>
public virtual void OnOperationResponse(OperationResponse operationResponse)
{
// if (operationResponse.ReturnCode != 0) this.DebugReturn(DebugLevel.ERROR, operationResponse.ToStringFull());
// use the "secret" or "token" whenever we get it. doesn't really matter if it's in AuthResponse.
if (operationResponse.Parameters.ContainsKey(ParameterCode.Secret))
{
if (this.AuthValues == null)
{
this.AuthValues = new AuthenticationValues();
//this.DebugReturn(DebugLevel.ERROR, "Server returned secret. Created AuthValues.");
}
this.AuthValues.Token = operationResponse[ParameterCode.Secret] as string;
}
switch (operationResponse.OperationCode)
{
case OperationCode.FindFriends:
if (operationResponse.ReturnCode != 0)
{
this.DebugReturn(DebugLevel.ERROR, "OpFindFriends failed: " + operationResponse.ToStringFull());
this.isFetchingFriendList = false;
break;
}
bool[] onlineList = operationResponse[ParameterCode.FindFriendsResponseOnlineList] as bool[];
string[] roomList = operationResponse[ParameterCode.FindFriendsResponseRoomIdList] as string[];
this.FriendList = new List<FriendInfo>(this.friendListRequested.Length);
for (int index = 0; index < this.friendListRequested.Length; index++)
{
FriendInfo friend = new FriendInfo();
friend.Name = this.friendListRequested[index];
friend.Room = roomList[index];
friend.IsOnline = onlineList[index];
this.FriendList.Insert(index, friend);
}
this.friendListRequested = null;
this.isFetchingFriendList = false;
this.friendListTimestamp = Environment.TickCount;
if (this.friendListTimestamp == 0)
{
this.friendListTimestamp = 1; // makes sure the timestamp is not accidentally 0
}
break;
case OperationCode.Authenticate:
{
if (operationResponse.ReturnCode != 0)
{
this.DebugReturn(DebugLevel.ERROR, operationResponse.ToStringFull() + " Server: " + this.Server + " Address: " + this.loadBalancingPeer.ServerAddress);
switch (operationResponse.ReturnCode)
{
case ErrorCode.InvalidAuthentication:
this.DisconnectedCause = DisconnectCause.InvalidAuthentication;
break;
case ErrorCode.CustomAuthenticationFailed:
this.DisconnectedCause = DisconnectCause.CustomAuthenticationFailed;
break;
case ErrorCode.InvalidRegion:
this.DisconnectedCause = DisconnectCause.InvalidRegion;
break;
case ErrorCode.MaxCcuReached:
this.DisconnectedCause = DisconnectCause.MaxCcuReached;
break;
case ErrorCode.OperationNotAllowedInCurrentState:
this.DisconnectedCause = DisconnectCause.OperationNotAllowedInCurrentState;
break;
}
this.State = ClientState.Disconnecting;
this.Disconnect();
break; // if auth didn't succeed, we disconnect (above) and exit this operation's handling
}
if (this.Server == ServerConnection.NameServer || this.Server == ServerConnection.MasterServer)
{
if (operationResponse.Parameters.ContainsKey(ParameterCode.UserId))
{
string incomingId = (string)operationResponse.Parameters[ParameterCode.UserId];
if (!string.IsNullOrEmpty(incomingId))
{
this.UserId = incomingId;
this.DebugReturn(DebugLevel.INFO, string.Format("Setting UserId sent by Server:{0}", this.UserId));
}
//.........这里部分代码省略.........