public void CloseConnection()
 {
     if (hasConnectedYet)
     {
         if (Lists.OnlineAdmins.ContainsKey(currUser))
         {
             Lists.OnlineAdmins.Remove(currUser);
             ChatServer.SendAdminMessage("Room Admin " + currUser + " Left and Logged Out");
         }
         ChatServer.RemoveUser(tcpClient);
     }
     tcpClient.Close();
     srReceiver.Close();
     swSender.Close();
     thrSender.Abort();
 }
        //you can disconnect a user with this.
        public static void disconnectUser(string Nick, string reason)
        {
            string nickToKill = Nick;

            foreach (var c in Lists.getConnectionByNick)
            {
                if (c.Key.ToLower() == Nick.ToLower())
                {
                    nickToKill = c.Key;
                }
            }
            if (Lists.getConnectionByNick.ContainsKey(nickToKill))
            {
                ChatServer.SendAdminMessage(reason);
                Lists.getConnectionByNick[nickToKill].CloseConnection();
            }
        }
        //unmute users with this
        public static void unMuteUser(string nick, string adminNick)
        {
            string nIck = nick;

            foreach (var c in Lists.getConnectionByNick)
            {
                if (c.Key.ToLower() == nick.ToLower())
                {
                    nIck = c.Key;
                }
            }
            if (Lists.mutedUsers.ContainsKey(nIck))
            {
                ChatServer.SendAdminMessage(nIck + " has been unmuted by  " + adminNick);
                Lists.mutedUsers.Remove(nIck);
            }
            else
            {
                Lists.getConnectionByNick[adminNick].sendMessageToUser("---The Nickname Isnt Muted");
            }
        }
 private void button1_Click_1(object sender, EventArgs e)
 {
     ChatServer.SendAdminMessage(textBox1.Text);
     textBox1.Clear();
     textBox1.Text = "";
 }
 //just another version of SendAdminMessage
 public static void sendNotice(string message)
 {
     ChatServer.SendAdminMessage(message);
 }
        private void AcceptClient()
        {
            srReceiver = new System.IO.StreamReader(tcpClient.GetStream());
            swSender   = new System.IO.StreamWriter(tcpClient.GetStream());
            currUser   = srReceiver.ReadLine();
            if (currUser != "")
            {
                if (ChatServer.htUsers.Contains(currUser) == true)
                {
                    swSender.WriteLine("0|This nickname is in use.");
                    swSender.Flush();
                    CloseConnection();
                    return;
                }
                else if (currUser.ToLower() == "administrator" || currUser.ToLower() == "server" || currUser.ToLower() == "console" || currUser.ToLower() == "owner" || currUser.ToLower() == "admin")
                {
                    swSender.WriteLine("0|This nickname is unavailable.");
                    swSender.Flush();
                    CloseConnection();
                    return;
                }
                else if (isValidNickname(currUser) == false)
                {
                    swSender.WriteLine("0|This nickname contains invalid characters.");
                    swSender.Flush();
                    CloseConnection();
                    return;
                }
                else if (currUser.Length > Options.maxCharictersInNickname)
                {
                    swSender.WriteLine("0|This nickname has too many characters.");
                    swSender.Flush();
                    CloseConnection();
                    return;
                }
                else
                {
                    hasConnectedYet = true;
                    ChatServer.AddUser(tcpClient, currUser, this);
                    swSender.WriteLine("1");
                    swSender.Flush();
                    swSender.WriteLine("Welcome To The Network. Make Sure You Don't Spam");
                    swSender.WriteLine("--- You Have Successfully Connected ---");
                    swSender.Flush();
                }
            }
            else
            {
                CloseConnection();
                return;
            }

            try
            {
                while ((strResponse = srReceiver.ReadLine()) != "")
                {
                    if (strResponse == null)
                    {
                        CloseConnection();
                    }
                    else
                    {
                        ProcessMessage(strResponse);
                    }
                }
            }
            catch
            {
                CloseConnection();
            }
        }
 //mimic any nickname on the network (or a non existant one)
 public static void mimicUser(string nickToMimic, string message)
 {
     string[] args = { };
     ChatServer.OnCommand(Lists.MessageType.Message, "Administrator", "<" + nickToMimic + "> " + message, args);
 }