AuthenticateOnFrontEnd









How do I use Authenticate On Front End
Below are practical examples compiled from projects for learning and reference purposes

Featured Snippets


File name: ChatClient.cs Copy
620         void IPhotonPeerListener.OnStatusChanged(StatusCode statusCode)
621         {
622             switch (statusCode)
623             {
624                 case StatusCode.Connect:
625                     this.chatPeer.EstablishEncryption();
626                     if (this.State == ChatState.ConnectingToNameServer)
627                     {
628                         this.State = ChatState.ConnectedToNameServer;
629                         this.listener.OnChatStateChange(this.State);
630                     }
631                     else if (this.State == ChatState.ConnectingToFrontEnd)
632                     {
633                         this.AuthenticateOnFrontEnd();
634                     }
635                     break;
636                 case StatusCode.EncryptionEstablished:
637                     // once encryption is availble, the client should send one (secure) authenticate. it includes the AppId (which identifies your app on the Photon Cloud)
638                     if (!this.didAuthenticate)
639                     {
640                         this.didAuthenticate = this.chatPeer.AuthenticateOnNameServer(this.AppId, this.AppVersion, this.chatRegion, this.UserId, this.CustomAuthenticationValues);
641                         if (!this.didAuthenticate)
642                         {
643                             ((IPhotonPeerListener) this).DebugReturn(DebugLevel.ERROR, "Error calling OpAuthenticate! Did not work. Check log output, CustomAuthenticationValues and if you're connected. State: " + this.State);
644                         }
645                     }
646                     break;
647                 case StatusCode.EncryptionFailedToEstablish:
648                     this.State = ChatState.Disconnecting;
649                     this.chatPeer.Disconnect();
650                     break;
651                 case StatusCode.Disconnect:
652                     if (this.State == ChatState.Authenticated)
653                     {
654                         this.ConnectToFrontEnd();
655                     }
656                     else
657                     {
658                         this.State = ChatState.Disconnected;
659                         this.listener.OnChatStateChange(ChatState.Disconnected);
660                         this.listener.OnDisconnected();
661                     }
662                     break;
663             }
664         }
File name: ChatClient.cs Copy
854         private bool AuthenticateOnFrontEnd()
855         {
856             if (CustomAuthenticationValues != null)
857             {
858                 var d = new Dictionary {{(byte)ChatParameterCode.Secret, CustomAuthenticationValues.Secret}};
859                 return this.chatPeer.OpCustom((byte)ChatOperationCode.Authenticate, d, true);
860             }
861             else
862             {
863                 Debug.WriteLine("Can't authenticate on front end server. CustomAuthValues is null");
864             }
865             return false;
866         }

AuthenticateOnFrontEnd 99 lượt xem

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