Esempio n. 1
0
        private void RefreshControl()
        {
            if (this.InvokeRequired)
            {
                BeginInvoke(new MethodInvoker(RefreshControl));
                return;
            }

            ClientTable.SuspendLayout();
            ClientTable.Rows.Clear();
            try
            {
                if (IsTcpAppServer)
                {
                    TcpAppServer appServer = Server as TcpAppServer;
                    //Thread lock to prevent race condition.
                    lock (appServer.AppClients)
                    {
                        foreach (TcpAppServerConnection c in appServer.AppClients)
                        {
                            ClientTable.Rows.Add(
                                c.Name + " | " + c.Connection.ClientIPAddress.ToString(),
                                c.Connection.Connected ? "Connected" : "-"
                                );
                        }
                    }
                }
                else
                {
                    foreach (TcpServerConnection c in Server.Clients)
                    {
                        ClientTable.Rows.Add(
                            c.ClientIPAddress.ToString(),
                            c.Connected ? "Connected" : "-"
                            );
                    }
                }
            }
            finally { ClientTable.ResumeLayout(); }
        }
Esempio n. 2
0
        /// <summary>
        /// Assign <see cref="TcpServer"/> object to control.
        /// </summary>
        /// <param name="server"></param>
        public void AssignObject(TcpServer server)
        {
            if (Server != null)
            {
                Server.ClientConnected    -= Server_ClientConnected;
                Server.ClientDisconnected -= Server_ClientDisconnected;
            }

            Server = server;
            TcpAppServer appServer = Server as TcpAppServer;

            IsTcpAppServer = (appServer != null);
            if (IsTcpAppServer)
            {
                appServer.ClientSignedIn     += AppServer_ClientSignedIn;
                appServer.ClientSigningOut   += AppServer_ClientSigningOut;
                appServer.ClientDisconnected += Server_ClientDisconnected;
            }
            else
            {
                Server.ClientConnected    += Server_ClientConnected;
                Server.ClientDisconnected += Server_ClientDisconnected;
            }
        }