本文整理汇总了C#中OperationResponse.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# OperationResponse.ToString方法的具体用法?C# OperationResponse.ToString怎么用?C# OperationResponse.ToString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OperationResponse
的用法示例。
在下文中一共展示了OperationResponse.ToString方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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)
{
//.........这里部分代码省略.........
示例2: 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;
}
//.........这里部分代码省略.........
示例3: 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
//.........这里部分代码省略.........
示例4: 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;
}
}
示例5: OnOperationResponse
public void OnOperationResponse(OperationResponse operationResponse)
{
Utility.Log(operationResponse.ToString());
}
示例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;
}
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;
//.........这里部分代码省略.........