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 SocketClient() { var remoteEndPoint = new IPEndPoint(IPAddress.Parse("127.0.0.1"), DEFAULT_PORT); var connector = new TcpClientConnector(); _connection = connector.ConnectTo(_connectionId, remoteEndPoint, ConnectionTimeout, OnConnectionEstablished, OnConnectionFailed); _connection.ConnectionClosed += OnConnectionClosed; _connection.ReceiveAsync(OnRawDataReceived); }
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); // 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; }