ChatDisconnectCause









How do I use Chat Disconnect Cause
Below are practical examples compiled from projects for learning and reference purposes

Featured Snippets


File name: ChatClient.cs Copy
52         public ChatDisconnectCause DisconnectedCause { get; private set; }
File name: ChatClient.cs Copy
94         public bool Connect(string address, ConnectionProtocol protocol, string appId, string appVersion, string userId, AuthenticationValues authValues)
95         {
96             if (!this.HasPeer)
97             {
98                 this.chatPeer = new ChatPeer(this, protocol);
99             }
100             else
101             {
102                 this.Disconnect();
103                 if (this.chatPeer.UsedProtocol != protocol)
104                 {
105                     this.chatPeer = new ChatPeer(this, protocol);
106                 }
107             }
108
109#if UNITY
110#pragma warning disable 0162 // the library variant defines if we should use PUN's SocketUdp variant (at all)
111             if (PhotonPeer.NoSocket)
112             {
113#if !UNITY_EDITOR && (UNITY_PS3 || UNITY_ANDROID)
114                 UnityEngine.Debug.Log("Using class SocketUdpNativeDynamic");
115                 this.chatPeer.SocketImplementation = typeof(SocketUdpNativeDynamic);
116#elif !UNITY_EDITOR && UNITY_IPHONE
117                 UnityEngine.Debug.Log("Using class SocketUdpNativeStatic");
118                 this.chatPeer.SocketImplementation = typeof(SocketUdpNativeStatic);
119#elif !UNITY_EDITOR && (UNITY_WINRT)
120                 // this automatically uses a separate assembly-file with Win8-style Socket usage (not possible in Editor)
121#else
122                 Type udpSocket = Type.GetType("ExitGames.Client.Photon.SocketUdp, Assembly-CSharp");
123                 this.chatPeer.SocketImplementation = udpSocket;
124                 if (udpSocket == null)
125                 {
126                     UnityEngine.Debug.Log("ChatClient could not find a suitable C# socket class. The Photon3Unity3D.dll only supports native socket plugins.");
127                 }
128#endif
129                 if (this.chatPeer.SocketImplementation == null)
130                 {
131                     UnityEngine.Debug.Log("No socket implementation set for 'NoSocket' assembly. Please contact Exit Games.");
132                 }
133             }
134#pragma warning restore 0162
135#endif
136
137             this.chatPeer.TimePingInterval = 3000;
138             this.DisconnectedCause = ChatDisconnectCause.None;
139
140             this.CustomAuthenticationValues = authValues;
141             this.UserId = userId;
142             this.AppId = appId;
143             this.AppVersion = appVersion;
144             this.didAuthenticate = false;
145             this.msDeltaForServiceCalls = 100;
146
147
148             // clean all channels
149             this.PublicChannels.Clear();
150             this.PrivateChannels.Clear();
151
152             if (!address.Contains(":"))
153             {
154                 int port = 0;
155                 ProtocolToNameServerPort.TryGetValue(protocol, out port);
156                 address = string.Format("{0}:{1}", address, port);
157             }
158
159             bool isConnecting = this.chatPeer.Connect(address, "NameServer");
160             if (isConnecting)
161             {
162                 this.State = ChatState.ConnectingToNameServer;
163             }
164             return isConnecting;
165         }
File name: ChatClient.cs Copy
768         private void HandleAuthResponse(OperationResponse operationResponse)
769         {
770             ((IPhotonPeerListener)this).DebugReturn(DebugLevel.INFO, operationResponse.ToStringFull() + " on: " + this.NameServerAddress);
771             if (operationResponse.ReturnCode == 0)
772             {
773                 if (this.State == ChatState.ConnectedToNameServer)
774                 {
775                     this.State = ChatState.Authenticated;
776                     this.listener.OnChatStateChange(this.State);
777
778                     if (operationResponse.Parameters.ContainsKey(ParameterCode.Secret))
779                     {
780                         if (this.CustomAuthenticationValues == null)
781                         {
782                             this.CustomAuthenticationValues = new AuthenticationValues();
783                         }
784                         this.CustomAuthenticationValues.Secret = operationResponse[ParameterCode.Secret] as string;
785                         this.FrontendAddress = (string) operationResponse[ParameterCode.Address];
786
787                         // we disconnect and status handler starts to connect to front end
788                         this.chatPeer.Disconnect();
789                     }
790                     else
791                     {
792                         //TODO: error reaction!
793                     }
794                 }
795                 else if (this.State == ChatState.ConnectingToFrontEnd)
796                 {
797                     this.msDeltaForServiceCalls = this.msDeltaForServiceCalls * 4; // when we arrived on chat server: limit Service calls some more
798
799                     this.State = ChatState.ConnectedToFrontEnd;
800                     this.listener.OnChatStateChange(this.State);
801                     this.listener.OnConnected();
802                 }
803             }
804             else
805             {
806                 //((IPhotonPeerListener)this).DebugReturn(DebugLevel.INFO, operationResponse.ToStringFull() + " NS: " + this.NameServerAddress + " FrontEnd: " + this.frontEndAddress);
807
808                 switch (operationResponse.ReturnCode)
809                 {
810                     case ErrorCode.InvalidAuthentication:
811                         this.DisconnectedCause = ChatDisconnectCause.InvalidAuthentication;
812                         break;
813                     case ErrorCode.CustomAuthenticationFailed:
814                         this.DisconnectedCause = ChatDisconnectCause.CustomAuthenticationFailed;
815                         break;
816                     case ErrorCode.InvalidRegion:
817                         this.DisconnectedCause = ChatDisconnectCause.InvalidRegion;
818                         break;
819                     case ErrorCode.MaxCcuReached:
820                         this.DisconnectedCause = ChatDisconnectCause.MaxCcuReached;
821                         break;
822                     case ErrorCode.OperationNotAllowedInCurrentState:
823                         this.DisconnectedCause = ChatDisconnectCause.OperationNotAllowedInCurrentState;
824                         break;
825                 }
826
827                 this.State = ChatState.Disconnecting;
828                 this.chatPeer.Disconnect();
829             }
830         }

Download file with original file name:ChatDisconnectCause

ChatDisconnectCause 112 lượt xem

Gõ tìm kiếm nhanh...