コード例 #1
0
        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);
        }
コード例 #2
0
 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;
 }