示例#1
0
        // Event Handlers
        private void SocketAcceptTimerOnElapsed(object sender, ElapsedEventArgs elapsedEventArgs)
        {
            if (Disposing)
                return;

            if (!Started)
                return;

            SocketAcceptTimer.Stop();

            TcpClient tcp;

            lock (Listener)
                tcp = Listener.AcceptTcpClient();

            var backend = new TcpClientBackend(tcp);

            Client c = new Client(backend);

            lock (Clients)
                Clients.Add(c);

            c.Start();

            SocketAcceptTimer.Start();
        }
示例#2
0
        public Client(IPAddress address, ushort port, bool udpBackend = false)
        {
            NetstClientBackend backend;

            Outgoing = true;

            if (udpBackend)
            {
                backend = new UdpClientBackend(address, port);
            }
            else
            {
                backend = new TcpClientBackend(address, port);
            }

            Backend = backend;
        }