public void OnAcceptTcpClient(IAsyncResult ar)
        {
            try
            {
                Socket socket = _listener.EndAcceptSocket(ar);
                Client cli = new Client(socket);

                if (OnConnect != null)
                {
                    OnConnect(cli);
                }
            }
            catch (Exception)
            {

            }

            try
            {
                _listener.BeginAcceptTcpClient(new AsyncCallback(OnAcceptTcpClient), null);
            }
            catch (Exception)
            {
                _isListening = false;
            }
        }
예제 #2
0
        void client_OnDisconnect(Client client)
        {
            Statistics.RemoveConnectedClient();

            lock (_cleanupPool)
            {
                lock (_cleanupPool)
                {
                    if (_cleanupPool.ContainsKey(client.UniqueId))
                        _cleanupPool.Remove(client.UniqueId);
                }
            }
        }
예제 #3
0
        void client_OnPolicyRequest(Client client)
        {
            Statistics.CountRequest();

            byte[] buf = Encoding.ASCII.GetBytes("<cross-domain-policy><allow-access-from domain=\"*\" to-ports=\"*\" /></cross-domain-policy>\0");

            try
            {
                client.Send(buf, 0, buf.Length);
            }
            catch (Exception)
            {
                try
                {
                    client.Stop();
                }
                catch (Exception) { }
            }
        }
예제 #4
0
        void _listener_OnConnect(Client client)
        {
            client.OnPolicyRequest += new Client.OnPolicyRequestDelegate(client_OnPolicyRequest);
            client.OnDisconnect += new Client.OnDisconnectDelegate(client_OnDisconnect);
            client.Start();
            Statistics.AddConnectedClient();

            lock (_cleanupPool)
            {
                _cleanupPool.Add(client.UniqueId, new CleanupEntry() { Client = client, TimeOfInsertion = DateTime.Now });
            }
        }