Start() public method

Starts the specified client.
public Start ( TcpClient client ) : void
client System.Net.Sockets.TcpClient The client.
return void
示例#1
0
        public void StartClientConnection(TcpClient client)
        {
            Connector conn = new Connector(Port);

            connections.Add(conn.ID, conn);

            Subscribe(conn);

            conn.Start(client);
            OnEvent(NewConnectionCreated, new ConnectionEventArgs(conn.ID));
        }
示例#2
0
        public void StartServerConnection()
        {
            if (IsConnectedToClients)
            {
                throw new InvalidOperationException("Cannot set up a server connection when already listening on clients.");
            }

            IsConnectedToServer = true;


            Connector conn = new Connector(Port);

            connections.Add(conn.ID, conn);

            TcpClient client = new TcpClient();

            Subscribe(conn);

            client.Connect(Host, Port);

            conn.Start(client);
            OnEvent(NewConnectionCreated, new ConnectionEventArgs(conn.ID));
        }
        public void StartClientConnection(TcpClient client)
        {


            Connector conn = new Connector(Port);

            connections.Add(conn.ID, conn);

            Subscribe(conn);

            conn.Start(client);
            OnEvent(NewConnectionCreated, new ConnectionEventArgs(conn.ID));

        }
        public void StartServerConnection()
        {
            if (IsConnectedToClients)
            {
                throw new InvalidOperationException("Cannot set up a server connection when already listening on clients.");
            }

            IsConnectedToServer = true;


            Connector conn = new Connector(Port);

            connections.Add(conn.ID, conn);

            TcpClient client = new TcpClient();

            Subscribe(conn);
            try
            {

                client.Connect(Host, Port);

                conn.Start(client);
                OnEvent(NewConnectionCreated, new ConnectionEventArgs(conn.ID));
            }
            catch (SocketException)
            {
                if (UnableToConnect != null)
                {
                    UnableToConnect(this, EventArgs.Empty);
                }
            }
            catch (Exception)
            {
                if (CrashOnException)
                {
                    throw;
                }
            }
        }