本文整理汇总了C#中ConnectionProtocol类的典型用法代码示例。如果您正苦于以下问题:C# ConnectionProtocol类的具体用法?C# ConnectionProtocol怎么用?C# ConnectionProtocol使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ConnectionProtocol类属于命名空间,在下文中一共展示了ConnectionProtocol类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: ChatPeer
public ChatPeer(IPhotonPeerListener listener, ConnectionProtocol protocol) : base(listener, protocol)
{
#if UNITY
#pragma warning disable 0162 // the library variant defines if we should use PUN's SocketUdp variant (at all)
if (PhotonPeer.NoSocket)
{
#if !UNITY_EDITOR && (UNITY_PS3 || UNITY_ANDROID)
UnityEngine.Debug.Log("Using class SocketUdpNativeDynamic");
this.SocketImplementation = typeof(SocketUdpNativeDynamic);
#elif !UNITY_EDITOR && UNITY_IPHONE
UnityEngine.Debug.Log("Using class SocketUdpNativeStatic");
this.SocketImplementation = typeof(SocketUdpNativeStatic);
#elif !UNITY_EDITOR && (UNITY_WINRT)
// this automatically uses a separate assembly-file with Win8-style Socket usage (not possible in Editor)
#else
Type udpSocket = Type.GetType("ExitGames.Client.Photon.SocketUdp, Assembly-CSharp");
this.SocketImplementation = udpSocket;
if (udpSocket == null)
{
UnityEngine.Debug.Log("ChatClient could not find a suitable C# socket class. The Photon3Unity3D.dll only supports native socket plugins.");
}
#endif
if (this.SocketImplementation == null)
{
UnityEngine.Debug.Log("No socket implementation set for 'NoSocket' assembly. Please contact Exit Games.");
}
}
#pragma warning restore 0162
if (protocol == ConnectionProtocol.WebSocket || protocol == ConnectionProtocol.WebSocketSecure) {
UnityEngine.Debug.Log("Using SocketWebTcp");
this.SocketImplementation = Type.GetType("ExitGames.Client.Photon.SocketWebTcp, Assembly-CSharp");//typeof(SocketWebTcp);
}
#endif
}
开发者ID:loursbrun,项目名称:sniperspiritV3,代码行数:34,代码来源:ChatPeer.cs
示例2: NetworkingPeer
public NetworkingPeer(IPhotonPeerListener listener, string playername, ConnectionProtocol connectionProtocol)
: base(listener, connectionProtocol)
{
#if UNITY_EDITOR || (!UNITY_IPHONE && !UNITY_ANDROID && !UNITY_PS3)
Debug.Log("Using C# Socket");
this.SocketImplementation = typeof(SocketUdp);
#elif !UNITY_EDITOR && UNITY_PS3
Debug.Log("Using class SocketUdpNativeDllImport");
this.SocketImplementation = typeof(SocketUdpNativeDllImport);
#elif !UNITY_EDITOR && UNITY_ANDROID
Debug.Log("Using class SocketUdpNativeDynamic");
this.SocketImplementation = typeof(SocketUdpNativeDynamic);
#elif !UNITY_EDITOR && UNITY_IPHONE
Debug.Log("Using class SocketUdpNativeStatic");
this.SocketImplementation = typeof(SocketUdpNativeStatic);
#endif
this.Listener = this;
// don't set the field directly! the listener is passed on to other classes, which get updated by the property set method
this.externalListener = listener;
this.PlayerName = playername;
this.mLocalActor = new PhotonPlayer(true, -1, this.playername);
this.AddNewPlayer(this.mLocalActor.ID, this.mLocalActor);
// RPC shortcut lookup creation (from list of RPCs, which is updated by Editor scripts)
rpcShortcuts = new Dictionary<string, int>(PhotonNetwork.PhotonServerSettings.RpcList.Count);
for (int index = 0; index < PhotonNetwork.PhotonServerSettings.RpcList.Count; index++)
{
var name = PhotonNetwork.PhotonServerSettings.RpcList[index];
rpcShortcuts[name] = index;
}
this.State = global::PeerState.PeerCreated;
}
开发者ID:acimbru,项目名称:licenta,代码行数:35,代码来源:NetworkingPeer.cs
示例3: SessionData
public SessionData(string sessionName, string hostName, int port, ConnectionProtocol protocol, string sessionConfig)
{
SessionName = sessionName;
Host = hostName;
Port = port;
Proto = protocol;
PuttySession = sessionConfig;
}
开发者ID:cooldroid,项目名称:PuttyWrap,代码行数:8,代码来源:SessionData.cs
示例4: Connect
public bool Connect(string address, ConnectionProtocol protocol)
{
if (this.UsedProtocol != protocol)
{
return false;
}
return true;
}
开发者ID:fackingbee,项目名称:Unity_Advance,代码行数:9,代码来源:ChatPeer.cs
示例5: TestClient
/// <summary>
/// Initializes a new instance of the <see cref = "TestClient" /> class.
/// </summary>
public TestClient(ConnectionProtocol connectionProtocol)
{
this.autoResetEventInit = new AutoResetEvent(false);
this.OperationResponseQueue = new Queue<OperationResponse>(1000);
this.EventQueue = new Queue<EventData>(1000);
this.PhotonClient = new LoadBalancingPeer(this, connectionProtocol) { DebugOut = DebugLevel.INFO };
this.fiber.Start();
}
开发者ID:ommziSolution,项目名称:PhotonServer,代码行数:12,代码来源:TestClient.cs
示例6: LoadbalancingOnlineTests
public LoadbalancingOnlineTests(string schemeName, ConnectionProtocol protocol)
: base(new OnlineConnectPolicy(GetAuthScheme(schemeName), protocol))
{
if (schemeName == "TokenLessAuthForOldClients" || schemeName == "TokenAuthNoUserIds")
{
this.Player1 = null;
this.Player2 = null;
this.Player3 = null;
}
}
开发者ID:JerryBian,项目名称:PhotonSample,代码行数:10,代码来源:LoadbalancingOnlineTests.cs
示例7: OnlineNUnitClient
/// <summary>
/// Initializes a new instance of the <see cref = "OnlineNUnitClient" /> class.
/// </summary>
public OnlineNUnitClient(ConnectionProtocol connectionProtocol, bool logPhotonClientMessages = false)
{
this.Id = Interlocked.Increment(ref curentId);
this.LogPhotonClientMessages = logPhotonClientMessages;
this.autoResetEventInit = new AutoResetEvent(false);
this.OperationResponseQueue = new Queue<OperationResponse>(1000);
this.EventQueue = new Queue<EventData>(1000);
this.Peer = new PhotonPeer(this, connectionProtocol) { DebugOut = DebugLevel.INFO };
this.fiber.Start();
}
开发者ID:JerryBian,项目名称:PhotonSample,代码行数:15,代码来源:OnlineNUnitClient.cs
示例8: GetPolicy
public static ConnectPolicy GetPolicy(string policyName, ConnectionProtocol protocol)
{
switch (policyName)
{
case "DEV":
// return new OnlineConnectPolicy(new TokenAuthenticationScheme(), protocol)
case "LIVE":
// return new OnlineConnectPolicy(new TokenAuthenticationScheme(), protocol);
case "LOCAL":
default:
return new OnlineConnectPolicy(new TokenAuthenticationScheme(), protocol);
}
}
开发者ID:JerryBian,项目名称:PhotonSample,代码行数:13,代码来源:PluginOnlineTests.cs
示例9: Start
public static Process Start(string serverAddress, string appId, ConnectionProtocol protocol, string photonCmdLine, string relativeWorkingDirectory)
{
if (CheckConnection(serverAddress, appId, protocol))
{
return null;
}
if (!IsLocalAddress(serverAddress))
{
throw new Exception(string.Format((string) "failed to establish connection to {0} using protocol {1}", serverAddress, protocol));
}
var path = FindPhoton();
Environment.CurrentDirectory += relativeWorkingDirectory;
return StartPhoton(serverAddress, appId, protocol, path, photonCmdLine);
}
开发者ID:JerryBian,项目名称:PhotonSample,代码行数:17,代码来源:PhotonStarter.cs
示例10: NetworkingPeer
public NetworkingPeer(IPhotonPeerListener listener, string playername, ConnectionProtocol connectionProtocol)
: base(listener, connectionProtocol)
{
this.Listener = this;
// don't set the field directly! the listener is passed on to other classes, which get updated by the property set method
this.externalListener = listener;
this.PlayerName = playername;
this.mLocalActor = new PhotonPlayer(true, -1, this.playername);
this.AddNewPlayer(this.mLocalActor.ID, this.mLocalActor);
// RPC shortcut lookup creation (from list of RPCs, which is updated by Editor scripts)
rpcShortcuts = new Dictionary<string, int>(PhotonNetwork.PhotonServerSettings.RpcList.Count);
for (int index = 0; index < PhotonNetwork.PhotonServerSettings.RpcList.Count; index++)
{
var name = PhotonNetwork.PhotonServerSettings.RpcList[index];
rpcShortcuts[name] = index;
}
this.State = global::PeerState.PeerCreated;
}
开发者ID:rmkeezer,项目名称:fpsgame,代码行数:21,代码来源:NetworkingPeer.cs
示例11: CheckConnection
private static bool CheckConnection(string serverAddress, string appId, ConnectionProtocol protocol)
{
var listner = new PhotonListener(false);
var peer = new PhotonPeer(listner, protocol);
if (!peer.Connect(serverAddress, appId))
{
return false;
}
var counter = 100;
while (--counter > 0)
{
peer.Service();
if (listner.WaitForConnection(0))
{
var res = peer.PeerState == PeerStateValue.Connected;
peer.Disconnect();
return res;
}
Thread.Sleep(50);
}
return false;
}
开发者ID:JerryBian,项目名称:PhotonSample,代码行数:24,代码来源:PhotonStarter.cs
示例12: LitePeer
/// <summary>
/// Creates a LitePeer instance to communicate with Photon with your selection of protocol.
/// We recommend UDP.
/// </summary>
/// <param name="listener">Your IPhotonPeerListener implementation.</param>
/// <param name="protocolType">Protocol to use to connect to Photon.</param>
public LitePeer(IPhotonPeerListener listener, ConnectionProtocol protocolType) : base(listener, protocolType)
{
}
开发者ID:JerryBian,项目名称:PhotonSample,代码行数:9,代码来源:LitePeer.cs
示例13: OpAuthenticateOnce
/// <summary>
/// Sends this app's appId and appVersion to identify this application server side.
/// This is an async request which triggers a OnOperationResponse() call.
/// </summary>
/// <remarks>
/// This operation makes use of encryption, if that is established before.
/// See: EstablishEncryption(). Check encryption with IsEncryptionAvailable.
/// This operation is allowed only once per connection (multiple calls will have ErrorCode != Ok).
/// </remarks>
/// <param name="appId">Your application's name or ID to authenticate. This is assigned by Photon Cloud (webpage).</param>
/// <param name="appVersion">The client's version (clients with differing client appVersions are separated and players don't meet).</param>
/// <param name="authValues">Optional authentication values. The client can set no values or a UserId or some parameters for Custom Authentication by a server.</param>
/// <param name="regionCode">Optional region code, if the client should connect to a specific Photon Cloud Region.</param>
/// <param name="encryptionMode"></param>
/// <param name="expectedProtocol"></param>
/// <returns>If the operation could be sent (has to be connected).</returns>
public virtual bool OpAuthenticateOnce(string appId, string appVersion, AuthenticationValues authValues, string regionCode, EncryptionMode encryptionMode, ConnectionProtocol expectedProtocol)
{
if (this.DebugOut >= DebugLevel.INFO)
{
this.Listener.DebugReturn(DebugLevel.INFO, "OpAuthenticate()");
}
var opParameters = new Dictionary<byte, object>();
// shortcut, if we have a Token
if (authValues != null && authValues.Token != null)
{
opParameters[ParameterCode.Secret] = authValues.Token;
return this.OpCustom(OperationCode.AuthenticateOnce, opParameters, true, (byte)0, false); // we don't have to encrypt, when we have a token (which is encrypted)
}
if (encryptionMode == EncryptionMode.DatagramEncryption && expectedProtocol != ConnectionProtocol.Udp)
{
Debug.LogWarning("Expected protocol set to UDP, due to encryption mode DatagramEncryption. Changing protocol in PhotonServerSettings from: " + PhotonNetwork.PhotonServerSettings.Protocol);
PhotonNetwork.PhotonServerSettings.Protocol = ConnectionProtocol.Udp;
expectedProtocol = ConnectionProtocol.Udp;
}
opParameters[ParameterCode.ExpectedProtocol] = (byte)expectedProtocol;
opParameters[ParameterCode.EncryptionMode] = (byte)encryptionMode;
opParameters[ParameterCode.AppVersion] = appVersion;
opParameters[ParameterCode.ApplicationId] = appId;
if (!string.IsNullOrEmpty(regionCode))
{
opParameters[ParameterCode.Region] = regionCode;
}
if (authValues != null)
{
if (!string.IsNullOrEmpty(authValues.UserId))
{
opParameters[ParameterCode.UserId] = authValues.UserId;
}
if (authValues.AuthType != CustomAuthenticationType.None)
{
opParameters[ParameterCode.ClientAuthenticationType] = (byte)authValues.AuthType;
if (!string.IsNullOrEmpty(authValues.Token))
{
opParameters[ParameterCode.Secret] = authValues.Token;
}
else
{
if (!string.IsNullOrEmpty(authValues.AuthGetParameters))
{
opParameters[ParameterCode.ClientAuthenticationParams] = authValues.AuthGetParameters;
}
if (authValues.AuthPostData != null)
{
opParameters[ParameterCode.ClientAuthenticationData] = authValues.AuthPostData;
}
}
}
}
return this.OpCustom(OperationCode.AuthenticateOnce, opParameters, true, (byte)0, this.IsEncryptionAvailable);
}
开发者ID:yuvadius,项目名称:need4bit,代码行数:80,代码来源:LoadbalancingPeer.cs
示例14: OpRaiseEvent
private readonly Dictionary<byte, object> opParameters = new Dictionary<byte, object>(); // used in OpRaiseEvent() (avoids lots of new Dictionary() calls)
#endregion Fields
#region Constructors
/// <summary>
/// Creates a Peer with selected connection protocol.
/// </summary>
/// <remarks>Each connection protocol has it's own default networking ports for Photon.</remarks>
/// <param name="protocolType">The preferred option is UDP.</param>
public LoadBalancingPeer(ConnectionProtocol protocolType)
: base(protocolType)
{
// this does not require a Listener, so:
// make sure to set this.Listener before using a peer!
}
开发者ID:yuvadius,项目名称:need4bit,代码行数:17,代码来源:LoadbalancingPeer.cs
示例15: StartPhoton
private static Process StartPhoton(string serverAddress, string appId, ConnectionProtocol protocol, string path, string photonCmdLine)
{
var process = Process.Start(path, photonCmdLine);
if (process == null)
{
throw new Exception("PhotonSocketServer.exe can not be started");
}
if (process.WaitForExit(6500))
{
throw new Exception(string.Format("'{0}' finished unexpectedly.", path));
}
// we try to connect to new process
var count = 15;
while (count-- > 0)
{
if (CheckConnection(serverAddress, appId, protocol))
{
return process;
}
if (process.WaitForExit(1000))
{
process.Close();
throw new Exception(string.Format("'{0}' finished unexpectedly", path));
}
}
process.CloseMainWindow();
if (!process.WaitForExit(1000))
{
process.Kill();
}
process.Close();
throw new Exception(string.Format("Unable to connect to address={1} and process {0}", path, serverAddress));
}
开发者ID:JerryBian,项目名称:PhotonSample,代码行数:37,代码来源:PhotonStarter.cs
示例16: Connect
public bool Connect(string address, ConnectionProtocol protocol, string appId, string appVersion, string userId, AuthenticationValues authValues)
{
if (!this.HasPeer)
{
this.chatPeer = new ChatPeer(this, protocol);
}
else
{
this.Disconnect();
if (this.chatPeer.UsedProtocol != protocol)
{
this.chatPeer = new ChatPeer(this, protocol);
}
}
// #pragma warning disable 0162 // the library variant defines if we should use PUN's SocketUdp variant (at all)
// if (PhotonPeer.NoSocket)
// {
// #if !UNITY_EDITOR && (UNITY_PS3 || UNITY_ANDROID)
// UnityEngine.Debug.Log("Chat uses class SocketUdpNativeDynamic");
// this.chatPeer.SocketImplementation = typeof(SocketUdpNativeDynamic);
// #elif !UNITY_EDITOR && UNITY_IPHONE
// UnityEngine.Debug.Log("Chat uses class SocketUdpNativeStatic");
// this.chatPeer.SocketImplementation = typeof(SocketUdpNativeStatic);
// #elif !UNITY_EDITOR && (UNITY_WINRT || UNITY_WP8)
// // this automatically uses a separate assembly-file with Win8-style Socket usage (not possible in Editor)
// #else
// UnityEngine.Debug.Log("Chat uses class SocketUdp (default)");
// this.chatPeer.SocketImplementation = typeof(SocketUdp);
// // PhotonHandler.PingImplementation defaults to PingMono
// #endif
//
// if (this.chatPeer.SocketImplementation == null)
// {
// UnityEngine.Debug.Log("No socket implementation set for 'NoSocket' assembly. Please contact Exit Games.");
// }
// }
// #pragma warning restore 0162
this.chatPeer.TimePingInterval = 3000;
this.DisconnectedCause = ChatDisconnectCause.None;
this.CustomAuthenticationValues = authValues;
this.UserId = userId;
this.AppId = appId;
this.AppVersion = appVersion;
this.didAuthenticate = false;
this.msDeltaForServiceCalls = 100;
// clean all channels
this.PublicChannels.Clear();
this.PrivateChannels.Clear();
if (!address.Contains(":"))
{
int port = 0;
ProtocolToNameServerPort.TryGetValue(protocol, out port);
address = string.Format("{0}:{1}", address, port);
}
bool isConnecting = this.chatPeer.Connect(address, "NameServer");
if (isConnecting)
{
this.State = ChatState.ConnectingToNameServer;
}
return isConnecting;
}
开发者ID:rbtk,项目名称:photon-test,代码行数:67,代码来源:ChatClient.cs
示例17: OpRaiseEvent
private readonly Dictionary<byte, object> opParameters = new Dictionary<byte, object>(); // used in OpRaiseEvent() (avoids lots of new Dictionary() calls)
#endregion Fields
#region Constructors
public LoadbalancingPeer(ConnectionProtocol protocolType)
: base(protocolType)
{
}
开发者ID:Ckeds,项目名称:PortfolioWorks,代码行数:10,代码来源:LoadbalancingPeer.cs
示例18: NetworkingPeer
public NetworkingPeer(IPhotonPeerListener listener, string playername, ConnectionProtocol connectionProtocol) : base(listener, connectionProtocol)
{
#if !UNITY_EDITOR && (UNITY_WINRT)
// this automatically uses a separate assembly-file with Win8-style Socket usage (not possible in Editor)
Debug.LogWarning("Using PingWindowsStore");
PhotonHandler.PingImplementation = typeof(PingWindowsStore); // but for ping, we have to set the implementation explicitly to Win 8 Store/Phone
#endif
#pragma warning disable 0162 // the library variant defines if we should use PUN's SocketUdp variant (at all)
if (PhotonPeer.NoSocket)
{
#if !UNITY_EDITOR && (UNITY_PS3 || UNITY_ANDROID)
Debug.Log("Using class SocketUdpNativeDynamic");
this.SocketImplementation = typeof(SocketUdpNativeDynamic);
PhotonHandler.PingImplementation = typeof(PingNativeDynamic);
#elif !UNITY_EDITOR && UNITY_IPHONE
Debug.Log("Using class SocketUdpNativeStatic");
this.SocketImplementation = typeof(SocketUdpNativeStatic);
PhotonHandler.PingImplementation = typeof(PingNativeStatic);
#elif !UNITY_EDITOR && (UNITY_WINRT)
// this automatically uses a separate assembly-file with Win8-style Socket usage (not possible in Editor)
#else
this.SocketImplementation = typeof (SocketUdp);
PhotonHandler.PingImplementation = typeof(PingMonoEditor);
#endif
if (this.SocketImplementation == null)
{
Debug.Log("No socket implementation set for 'NoSocket' assembly. Please contact Exit Games.");
}
}
#pragma warning restore 0162
if (PhotonHandler.PingImplementation == null)
{
PhotonHandler.PingImplementation = typeof(PingMono);
}
this.Listener = this;
this.lobby = TypedLobby.Default;
this.LimitOfUnreliableCommands = 40;
// don't set the field directly! the listener is passed on to other classes, which get updated by the property set method
this.externalListener = listener;
this.PlayerName = playername;
this.mLocalActor = new PhotonPlayer(true, -1, this.playername);
this.AddNewPlayer(this.mLocalActor.ID, this.mLocalActor);
// RPC shortcut lookup creation (from list of RPCs, which is updated by Editor scripts)
rpcShortcuts = new Dictionary<string, int>(PhotonNetwork.PhotonServerSettings.RpcList.Count);
for (int index = 0; index < PhotonNetwork.PhotonServerSettings.RpcList.Count; index++)
{
var name = PhotonNetwork.PhotonServerSettings.RpcList[index];
rpcShortcuts[name] = index;
}
this.State = global::PeerState.PeerCreated;
}
开发者ID:JonasSkaug,项目名称:afgangsprojekt-team-tj,代码行数:58,代码来源:NetworkingPeer.cs
示例19: SwitchToProtocol
/// <summary>
/// While offline, the network protocol can be switched (which affects the ports you can use to connect).
/// </summary>
/// <remarks>
/// When you switch the protocol, make sure to also switch the port for the master server. Default ports are:
/// TCP: 4530
/// UDP: 5055
///
/// This could look like this:<br/>
/// Connect(serverAddress, <udpport|tcpport>, appID, gameVersion)
///
/// Or when you use ConnectUsingSettings(), the PORT in the settings can be switched like so:<br/>
/// PhotonNetwork.PhotonServerSettings.ServerPort = 4530;
///
/// The current protocol can be read this way:<br/>
/// PhotonNetwork.networkingPeer.UsedProtocol
///
/// This does not work with the native socket plugin of PUN+ on mobile!
/// </remarks>
/// <param name="cp">Network protocol to use as low level connection. UDP is default. TCP is not available on all platforms (see remarks).</param>
public static void SwitchToProtocol(ConnectionProtocol cp)
{
if (networkingPeer.UsedProtocol == cp)
{
return;
}
try
{
networkingPeer.Disconnect();
networkingPeer.StopThread();
}
catch
{
}
// set up a new NetworkingPeer
NetworkingPeer newPeer = new NetworkingPeer(photonMono, String.Empty, cp);
newPeer.mAppVersion = networkingPeer.mAppVersion;
newPeer.CustomAuthenticationValues = networkingPeer.CustomAuthenticationValues;
newPeer.PlayerName= networkingPeer.PlayerName;
newPeer.mLocalActor = networkingPeer.mLocalActor;
newPeer.DebugOut = networkingPeer.DebugOut;
newPeer.CrcEnabled = networkingPeer.CrcEnabled;
newPeer.lobby = networkingPeer.lobby;
newPeer.LimitOfUnreliableCommands = networkingPeer.LimitOfUnreliableCommands;
newPeer.SentCountAllowance = networkingPeer.SentCountAllowance;
newPeer.TrafficStatsEnabled = networkingPeer.TrafficStatsEnabled;
networkingPeer = newPeer;
Debug.LogWarning("Protocol switched to: " + cp + ".");
}
开发者ID:Solestis,项目名称:SpyGameUnity5,代码行数:52,代码来源:PhotonNetwork.cs
示例20: GetDefaultPort
public static int GetDefaultPort(ConnectionProtocol protocol)
{
int port = 22;
switch (protocol)
{
case ConnectionProtocol.Raw:
break;
case ConnectionProtocol.Rlogin:
port = 513;
break;
case ConnectionProtocol.Serial:
break;
case ConnectionProtocol.Telnet:
port = 23;
break;
}
return port;
}
开发者ID:keramist,项目名称:superputty,代码行数:18,代码来源:dlgEditSession.cs
注:本文中的ConnectionProtocol类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论