UsedProtocol









How do I use Used Protocol
Below are practical examples compiled from projects for learning and reference purposes

Featured Snippets


File name: NetworkingPeer.cs Copy
294     public bool ConnectToNameServer()
295     {
296         if (PhotonHandler.AppQuits)
297         {
298             Debug.LogWarning("Ignoring Connect() because app gets closed. If this is an error, check PhotonHandler.AppQuits.");
299             return false;
300         }
301
302         IsUsingNameServer = true;
303         this.CloudRegion = CloudRegionCode.none;
304
305         if (this.State == global::PeerState.ConnectedToNameServer)
306         {
307             return true;
308         }
309
310         #if RHTTP
311         string address = (this.UsedProtocol == ConnectionProtocol.RHttp) ? this.NameServerAddressHttp : this.NameServerAddress;
312         #else
313         string address = this.NameServerAddress;
314         #endif
315
316         if (!address.Contains(":"))
317         {
318             int port = 0;
319             ProtocolToNameServerPort.TryGetValue(this.UsedProtocol, out port);
320             address = string.Format("{0}:{1}", address, port);
321             Debug.Log("Server to connect to: " + address + " settings protocol: " + PhotonNetwork.PhotonServerSettings.Protocol);
322         }
323         if (!base.Connect(address, "ns"))
324         {
325             return false;
326         }
327
328         this.State = global::PeerState.ConnectingToNameServer;
329         return true;
330     }
File name: NetworkingPeer.cs Copy
336     public bool ConnectToRegionMaster(CloudRegionCode region)
337     {
338         if (PhotonHandler.AppQuits)
339         {
340             Debug.LogWarning("Ignoring Connect() because app gets closed. If this is an error, check PhotonHandler.AppQuits.");
341             return false;
342         }
343
344         IsUsingNameServer = true;
345         this.CloudRegion = region;
346
347         if (this.State == global::PeerState.ConnectedToNameServer)
348         {
349             return this.OpAuthenticate(this.mAppId, this.mAppVersionPun, this.PlayerName, this.CustomAuthenticationValues, region.ToString());
350         }
351
352         #if RHTTP
353         string address = (this.UsedProtocol == ConnectionProtocol.RHttp) ? this.NameServerAddressHttp : this.NameServerAddress;
354         #else
355         string address = this.NameServerAddress;
356         #endif
357
358         if (!address.Contains(":"))
359         {
360             int port = 0;
361             ProtocolToNameServerPort.TryGetValue(this.UsedProtocol, out port);
362             address = string.Format("{0}:{1}", address, port);
363             //Debug.Log("Server to connect to: "+ address + " settings protocol: " + PhotonNetwork.PhotonServerSettings.Protocol);
364         }
365         if (!base.Connect(address, "ns"))
366         {
367             return false;
368         }
369
370         this.State = global::PeerState.ConnectingToNameServer;
371         return true;
372     }
File name: PhotonNetwork.cs Copy
1025     /// Connect(serverAddress, , appID, gameVersion)
1036     public static void SwitchToProtocol(ConnectionProtocol cp)
1037     {
1038         if (networkingPeer.UsedProtocol == cp)
1039         {
1040             return;
1041         }
1042         try
1043         {
1044             networkingPeer.Disconnect();
1045             networkingPeer.StopThread();
1046         }
1047         catch
1048         {
1049
1050         }
1051
1052         // set up a new NetworkingPeer
1053         NetworkingPeer newPeer = new NetworkingPeer(photonMono, String.Empty, cp);
1054         newPeer.mAppVersion = networkingPeer.mAppVersion;
1055         newPeer.CustomAuthenticationValues = networkingPeer.CustomAuthenticationValues;
1056         newPeer.PlayerName= networkingPeer.PlayerName;
1057         newPeer.mLocalActor = networkingPeer.mLocalActor;
1058         newPeer.DebugOut = networkingPeer.DebugOut;
1059         newPeer.CrcEnabled = networkingPeer.CrcEnabled;
1060         newPeer.lobby = networkingPeer.lobby;
1061         newPeer.LimitOfUnreliableCommands = networkingPeer.LimitOfUnreliableCommands;
1062         newPeer.SentCountAllowance = networkingPeer.SentCountAllowance;
1063         newPeer.TrafficStatsEnabled = networkingPeer.TrafficStatsEnabled;
1064
1065         networkingPeer = newPeer;
1066         Debug.LogWarning("Protocol switched to: " + cp + ".");
1067     }
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: ChatPeer.cs Copy
21         public bool Connect(string address, ConnectionProtocol protocol)
22         {
23             if (this.UsedProtocol != protocol)
24             {
25                 return false;
26             }
27
28             return true;
29         }

UsedProtocol 117 lượt xem

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