/// <summary> /// Connects to a remote asynchronously. /// </summary> /// <param name="ip">The IP address of the server.</param> /// <param name="port">The port of the server.</param> /// <param name="noDelay">Whether to disable Nagel's algorithm or not.</param> /// <param name="callback">The callback to make when the connection attempt completes.</param> public void ConnectInBackground(IPAddress ip, int port, bool noDelay, DarkRiftClient.ConnectCompleteHandler callback = null) { Client.ConnectInBackground( ip, port, noDelay, delegate(Exception e) { if (callback != null) { if (invokeFromDispatcher) { Dispatcher.InvokeAsync(() => callback(e)); } else { callback.Invoke(e); } } if (ConnectionState == ConnectionState.Connected) { Debug.Log("Connected to " + ip + " on port " + port + "."); } else { Debug.Log("Connection failed to " + ip + " on port " + port + "."); } } ); }
/// <summary> /// Connects to a remote asynchronously. /// </summary> /// <param name="ip">The IP address of the server.</param> /// <param name="port">The port of the server.</param> /// <param name="noDelay">Whether to disable Nagel's algorithm or not.</param> /// <param name="callback">The callback to make when the connection attempt completes.</param> public void ConnectInBackground(IPAddress ip, int port, bool noDelay, DarkRiftClient.ConnectCompleteHandler callback = null) { if (Client == null) { Initialize(); } Client.ConnectInBackground( ip, port, noDelay, delegate(Exception e) { if (callback != null) { if (invokeFromDispatcher) { Dispatcher.InvokeAsync(() => callback(e)); } else { callback.Invoke(e); } } LogConnectionStatus(ip, port.ToString()); } ); }
/// <summary> /// Connects to a remote asynchronously. /// </summary> /// <param name="ip">The IP address of the server.</param> /// <param name="port">The port of the server.</param> /// <param name="callback">The callback to make when the connection attempt completes.</param> public void ConnectInBackground(IPAddress ip, int port, IPVersion ipVersion, DarkRiftClient.ConnectCompleteHandler callback = null) { enetConnnection = new EnetClientConnection(ip.ToString(), port); Client.ConnectInBackground(enetConnnection, delegate(Exception e) { if (callback != null) { if (invokeFromDispatcher) { Dispatcher.InvokeAsync(() => callback(e)); } else { callback.Invoke(e); } } if (ConnectionState == ConnectionState.Connected) { Debug.Log("Connected to " + ip + " on port " + port + " using " + ipVersion + "."); } else { Debug.Log("Connection failed to " + ip + " on port " + port + " using " + ipVersion + "."); } } ); }
// Connect to a remote asynchronously. public void ConnectInBackground(DarkRiftClient.ConnectCompleteHandler callback = null) { _darkRiftClient.ConnectInBackground(_ip, Port, IpVersion, delegate(Exception e) { if (callback != null) { if (_invokeFromDispatcher) { _dispatcher.InvokeAsync(() => callback(e)); } else { callback.Invoke(e); } } _dispatcher.InvokeAsync( delegate { if (Connected) { Debug.Log("Connected to " + _ip + " on port " + Port + " using " + IpVersion + "."); } else { Debug.Log("Connection failed to " + _ip + " on port " + Port + " using " + IpVersion + "."); } } ); } ); }
#pragma warning disable 0618 // Implementing obsolete functionality public void ConnectInBackground(IPAddress ip, int port, IPVersion ipVersion, DarkRiftClient.ConnectCompleteHandler callback = null) { Client.ConnectInBackground( ip, port, ipVersion, delegate(Exception e) { if (callback != null) { if (eventsFromDispatcher) { Dispatcher.InvokeAsync(() => callback(e)); } else { callback.Invoke(e); } } if (ConnectionState == ConnectionState.Connected) { Debug.Log("Connected to " + ip + " on port " + port + " using " + ipVersion + "."); } else { Debug.Log("Connection failed to " + ip + " on port " + port + " using " + ipVersion + "."); } } ); #pragma warning restore 0618 // Implementing obsolete functionality }
/// <summary> /// Connects to a remote asynchronously. /// </summary> /// <param name="host">The host to connect to.</param> /// <param name="port">The port of the server.</param> /// <param name="noDelay">Whether to disable Nagel's algorithm or not.</param> /// <param name="callback">The callback to make when the connection attempt completes.</param> public void ConnectInBackground(string host, int port, bool noDelay, DarkRiftClient.ConnectCompleteHandler callback = null) { ConnectInBackground( Dns.GetHostAddresses(host)[0], port, noDelay, callback ); }
/// <summary> /// Connects to a remote asynchronously. /// </summary> /// <param name="ip">The IP address of the server.</param> /// <param name="port">The port of the server.</param> /// <param name="callback">The callback to make when the connection attempt completes.</param> public void ConnectInBackground(IPAddress ip, int port, IPVersion ipVersion, DarkRiftClient.ConnectCompleteHandler callback = null) { Client.ConnectInBackground( ip, port, ipVersion, delegate (Exception e) { if (callback != null) { if (invokeFromDispatcher) Dispatcher.InvokeAsync(() => callback(e)); else callback.Invoke(e); } if (Connected) Debug.Log("Connected to " + ip + " on port " + port + " using " + ipVersion + "."); else Debug.Log("Connection failed to " + ip + " on port " + port + " using " + ipVersion + "."); } ); }
/// <summary> /// Connects to a remote asynchronously. /// </summary> /// <param name="ip">The IP address of the server.</param> /// <param name="tcpPort">The port the server is listening on for TCP.</param> /// <param name="udpPort">The port the server is listening on for UDP.</param> /// <param name="noDelay">Whether to disable Nagel's algorithm or not.</param> /// <param name="callback">The callback to make when the connection attempt completes.</param> public void ConnectInBackground(IPAddress ip, int tcpPort, int udpPort, bool noDelay, DarkRiftClient.ConnectCompleteHandler callback = null) { Client.ConnectInBackground( ip, tcpPort, udpPort, noDelay, delegate(Exception e) { if (callback != null) { if (invokeFromDispatcher) { Dispatcher.InvokeAsync(() => callback(e)); } else { callback.Invoke(e); } } LogConnectionStatus(ip, $"{tcpPort} and {udpPort}"); } ); }