HandleAuthResponse









How do I use Handle Auth Response
Below are practical examples compiled from projects for learning and reference purposes

Featured Snippets


File name: ChatClient.cs Copy
598         void IPhotonPeerListener.OnOperationResponse(OperationResponse operationResponse)
599         {
600             switch (operationResponse.OperationCode)
601             {
602                 case (byte)ChatOperationCode.Authenticate:
603                     this.HandleAuthResponse(operationResponse);
604                     break;
605
606                 // the following operations usually don't return useful data and no error.
607                 case (byte)ChatOperationCode.Subscribe:
608                 case (byte)ChatOperationCode.Unsubscribe:
609                 case (byte)ChatOperationCode.Publish:
610                 case (byte)ChatOperationCode.SendPrivate:
611                 default:
612                     if (operationResponse.ReturnCode != 0)
613                     {
614                         ((IPhotonPeerListener)this).DebugReturn(DebugLevel.ERROR, string.Format("Chat Operation {0} failed (Code: {1}). Debug Message: {2}", operationResponse.OperationCode, operationResponse.ReturnCode, operationResponse.DebugMessage));
615                     }
616                     break;
617             }
618         }
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         }

HandleAuthResponse 113 lượt xem

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