IPhotonPeerListener Photon客户端回调接口
1: //只要有来自Photon Server的事件就触发
2: public virtual void OnEvent( EventData photonEvent )
3: {
4: this.DebugReturn( String.Format( "OnEvent: {0}", photonEvent.ToStringFull() ) );
5: }
6:
7: //当状态改变时调用
8: public virtual void OnStatusChanged( StatusCode statusCode )
9: {
10: this.DebugReturn( String.Format( "OnStatusChanged: {0}", statusCode ) );
11:
12: switch (statusCode)
13: {
14: case StatusCode.Connect:
15: this.State = ClientState.Connected;
16: break;
17: case StatusCode.Disconnect:
18: this.State = ClientState.Disconnected;
19: this.ActorNumber = 0;
20: break;
21: case StatusCode.ExceptionOnConnect:
22: this.OfflineReason = "Connection failed.\nIs the server online? Firewall open?";
23: break;
24: case StatusCode.SecurityExceptionOnConnect:
25: this.OfflineReason = "Security Exception on connect.\nMost likely, the policy request failed.\nIs Photon and the Policy App running?";
26: break;
27: case StatusCode.Exception:
28: this.OfflineReason = "Communication terminated by Exception.\nProbably the server shutdown locally.\nOr the network connection terminated.";
29: break;
30: case StatusCode.TimeoutDisconnect:
31: this.OfflineReason = "Disconnect due to timeout.\nProbably the server shutdown locally.\nOr the network connection terminated.";
32: break;
33: case StatusCode.DisconnectByServer:
34: this.OfflineReason = "Timeout Disconnect by server.\nThe server did not get responses in time.";
35: break;
36: case StatusCode.DisconnectByServerLogic:
37: this.OfflineReason = "Disconnect by server.\nThe servers logic (application) disconnected this client for some reason.";
38: break;
39: case StatusCode.DisconnectByServerUserLimit:
40: this.OfflineReason = "Server reached it's user limit.\nThe server is currently not accepting connections.\nThe license does not allow it.";
41: break;
42: default:
43: this.DebugReturn( "StatusCode not handled: " + statusCode );
44: break;
45: }
46: }
47:
48: //当操作响应时调用
49: public virtual void OnOperationResponse( OperationResponse operationResponse )
50: {
51: this.DebugReturn( String.Format( "OnOperationResponse: {0}", operationResponse.ToStringFull() ) );
52:
53: switch (operationResponse.OperationCode)
54: {
55: case (byte)LiteOpCode.Join:
56: this.State = ClientState.InRoom;
57: this.ActorNumber = (int)operationResponse[(byte)LiteOpKey.ActorNr];
58: break;
59: case (byte)LiteOpCode.Leave:
60: this.State = ClientState.Connected;
61: break;
62: }
63: }
64:
65: //服务端主动发出的信息通知
66: public void DebugReturn( DebugLevel level, string message )
67: {
68: this.DebugReturn( message );
69: }