Esempio n. 1
0
        void connectivityCheckThread()
        {
            CheckConnectivity = true;
            while (CheckConnectivity) // WHY WONT TIS UPDATE?
            {
                int i = 0;
                while (i < Clients.Count)
                {
                    try
                    {
                        AClient a = Clients[i];
                        if (!a.IsConnected)
                        {
                            // Closing the connection on our side automatically removes it from client list.
                            a.Close();
                        }
                        else
                        {
                            i++;
                        }
                    }
                    catch (Exception ex)
                    {
                        Core.HandleEx("AServer:connectivityCheckThread", ex);
                    }
                }

                Thread.Sleep(500);
            }
        }
Esempio n. 2
0
        // A client disconnects.
        void NewClient_OnClientDisconnect(AClient c)
        {
            Clients.Remove(c);

            if (OnClientDisconnect != null)
            {
                OnClientDisconnect();
            }
        }
Esempio n. 3
0
        public bool Equals(AClient obj)
        {
            // If parameter is null return false
            if ((object)obj == null)
            {
                return(false);
            }

            // Return true if the fields match
            return(this.ClientID == obj.ClientID);
        }
Esempio n. 4
0
        public static AClient StartClientConnection(Socket nSocket)
        {
            try
            {
                AClient a = new AClient(nSocket, true);

                // Perform startup communications before being officially added to the server.
                // Or null if it does not pass for a new connection.

                return(a);
            }
            catch (Exception ex)
            {
                Core.HandleEx("AClient:StartClientConnection", ex);
                return(null);
            }
        }
Esempio n. 5
0
        public override bool Equals(object obj)
        {
            // If parameter is null return false
            if (obj == null)
            {
                return(false);
            }

            // If paramter cannot be cast to PhilesClient return false
            AClient c = obj as AClient;

            if ((System.Object)c == null)
            {
                return(false);
            }

            // Return true if the fields match
            return(this.ClientID == c.ClientID);
        }
Esempio n. 6
0
        // Handles New Clients
        void ASListener_OnClientConnect(Socket nSocket)
        {
            try
            {
                AClient NewClient = AClient.StartClientConnection(nSocket);
                if (NewClient != null)
                {
                    NewClient.OnDataRead         += new AClient.DataReadDelegate(NewClient_OnDataRead);
                    NewClient.OnClientDisconnect += new AClient.ClientDisconnectDelegate(NewClient_OnClientDisconnect);
                    Clients.Add(NewClient);

                    if (OnClientConnect != null)
                    {
                        OnClientConnect();
                    }
                }
            }
            catch (Exception ex)
            {
                Core.HandleEx("AServer:ASListener_OnClientConnect", ex);
            }
        }
Esempio n. 7
0
 void NewClient_OnDataRead(byte[] data, AClient client)
 {
     Protocol.ReceiveData(data, client);
 }