public static ITcpConnection CreateAcceptedTcpConnection(Guid connectionId, IPEndPoint remoteEndPoint, Socket socket) { var connection = new TcpConnection(connectionId, remoteEndPoint); connection.InitSocket(socket); return(connection); }
public static ITcpConnection CreateConnectingTcpConnection(Guid connectionId, IPEndPoint localEndPoint, IPEndPoint remoteEndPoint, TcpClientConnector connector, Action <ITcpConnection> onConnectionEstablished, Action <ITcpConnection, SocketError> onConnectionFailed) { var connection = new TcpConnection(connectionId, remoteEndPoint); connector.InitConnect(localEndPoint, remoteEndPoint, (_, socket) => { connection.InitSocket(socket); if (onConnectionEstablished != null) { onConnectionEstablished(connection); } }, (_, socketError) => { if (onConnectionFailed != null) { onConnectionFailed(connection, socketError); } }, connection); return(connection); }
public static ITcpConnection CreateConnectingTcpConnection(Guid connectionId, IPEndPoint remoteEndPoint, TcpClientConnector connector, TimeSpan connectionTimeout, Action <ITcpConnection> onConnectionEstablished, Action <ITcpConnection, SocketError> onConnectionFailed, bool verbose) { var connection = new TcpConnection(connectionId, remoteEndPoint, verbose); connector.InitConnect(remoteEndPoint, (_, socket) => { connection.InitSocket(socket); if (onConnectionEstablished != null) { onConnectionEstablished(connection); } }, (_, socketError) => { if (onConnectionFailed != null) { onConnectionFailed(connection, socketError); } }, connection, connectionTimeout); return(connection); }
public static ITcpConnection CreateConnectingTcpConnection(Guid connectionId, IPEndPoint remoteEndPoint, TcpClientConnector connector, TimeSpan connectionTimeout, Action<ITcpConnection> onConnectionEstablished, Action<ITcpConnection, SocketError> onConnectionFailed, bool verbose) { var connection = new TcpConnection(connectionId, remoteEndPoint, verbose); // ReSharper disable ImplicitlyCapturedClosure connector.InitConnect(remoteEndPoint, (_, socket) => { connection.InitSocket(socket); if (onConnectionEstablished != null) onConnectionEstablished(connection); }, (_, socketError) => { if (onConnectionFailed != null) onConnectionFailed(connection, socketError); }, connection, connectionTimeout); // ReSharper restore ImplicitlyCapturedClosure return connection; }
public static ITcpConnection CreateAcceptedTcpConnection(Guid connectionId, IPEndPoint remoteEndPoint, Socket socket, bool verbose) { var connection = new TcpConnection(connectionId, remoteEndPoint, verbose); connection.InitSocket(socket); return connection; }
public static ITcpConnection CreateConnectingTcpConnection(Guid connectionId, IPEndPoint localEndPoint, IPEndPoint remoteEndPoint, TcpClientConnector connector, Action<ITcpConnection> onConnectionEstablished, Action<ITcpConnection, SocketError> onConnectionFailed) { var connection = new TcpConnection(connectionId, remoteEndPoint); connector.InitConnect(localEndPoint, remoteEndPoint, (_, socket) => { connection.InitSocket(socket); if (onConnectionEstablished != null) onConnectionEstablished(connection); }, (_, socketError) => { if (onConnectionFailed != null) onConnectionFailed(connection, socketError); }, connection); return connection; }