예제 #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();
        }
예제 #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)
     {
     }
 }
예제 #3
0
파일: Client.cs 프로젝트: umby24/ZBase
        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);
            //}
        }
예제 #4
0
 public void AcceptClient(TcpClient incomingClient)
 {
     _baseSocket.Accept(incomingClient);
 }
예제 #5
0
        public Socket ListenPort()
        {
            var connection = ClientSocket.Accept();

            return(connection);
        }