ConnectToFrontEnd
How do I use Connect To Front End
Below are practical examples compiled from projects for learning and reference purposes
Featured Snippets
Line | Code | Ex.. |
---|---|---|
654 | this.ConnectToFrontEnd(); | 1 |
847 | private void ConnectToFrontEnd() | 2 |
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
847 private void ConnectToFrontEnd()
848 {
849 this.State = ChatState.ConnectingToFrontEnd;
850
851 this.chatPeer.Connect(this.FrontendAddress, ChatApppName);
852 }
ConnectToFrontEnd 111 lượt xem
Gõ tìm kiếm nhanh...