Beispiel #1
0
        private void AcceptCallback(IAsyncResult ar) {
            var client = _listener.EndAcceptTcpClient(ar);
            var newSocket = new ClientSocket();
            newSocket.Disconnected += NewSocket_Disconnected;
            newSocket.Accept(client);

            WriteToBox("Accepted Client!!!");
            AcceptFunction();
        }
Beispiel #2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="host"></param>
 /// <param name="port"></param>
 public void Connect(string host = "localhost", int port = 30001)
 {
     try
     {
         client = new ClientSocket();
         client.DataReceived += Client_DataReceived;
         client.Disconnected += Client_Disconnected;
         client.Connected    += Client_Connected;
         client.Accept(new TcpClient(host, port));
     }
     catch (Exception ex)
     {
     }
 }
Beispiel #3
0
        public Client(TcpClient sock)
        {
            DataAvailable = false;
            // -- Instantiate our needed items
            _receiveBuffer = new ByteBuffer();
            SendBuffer     = new ByteBuffer();
            _socket        = new ClientSocket();
            BlockChanges   = new ConcurrentQueue <SetBlockServer>();
            ChatBuffer     = "";
            PopulatePackets();

            // -- Register events
            _socket.DataReceived += SocketOnDataReceived;
            _socket.Disconnected += SocketOnDisconnected;
            SendBuffer.DataAdded += SendBufferOnDataAdded;
            _canReceive           = true;
            _disconnectOnSend     = false;

            Ip = ((IPEndPoint)(sock.Client.RemoteEndPoint)).Address.ToString();

            // -- Assign the TcpClient to our ClientSocket, to make it start handling events.
            _socket.Accept(sock);
            _lastActive = DateTime.UtcNow;

            // -- Setup the timeout task
            Interval = TimeSpan.FromSeconds(1);
            _taskId  = Ip + new Random().Next(2035, 193876957);
            _taskId  = TaskScheduler.RegisterTask(_taskId, this);

            Kick("You suck lol");
            //Server.RegisterClient(this);

            //if (Player.Database.IsIpBanned(Ip)) {
            //    Kick(BannedMessage);
            //}
        }
Beispiel #4
0
 public void AcceptClient(TcpClient incomingClient)
 {
     _baseSocket.Accept(incomingClient);
 }
Beispiel #5
0
        public Socket ListenPort()
        {
            var connection = ClientSocket.Accept();

            return(connection);
        }