private ArrayList _users; // SimpleUser objects

        #endregion Fields

        #region Constructors

        /// <summary>
        /// Create a new Channel
        /// </summary>
        public Channel(string name, IRCServer server, SimpleUser op)
        {
            Console.WriteLine("new {0} with name: {1}, is available", this, name);
            this._modes = new IRCChannelMode();
            this._name = name;
            this._topic = String.Empty;
            this._members = new ArrayList();
            this._users = new ArrayList();
            this._server = server;
        }
        /// <summary>
        /// Remove a SimpleUser object
        /// </summary>
        /// <param name="user">SimpleUser to remove</param>
        public virtual void RemoveUser(SimpleUser user)
        {
            if (user == null)
                throw new ArgumentNullException("user");

            lock (this._users)
            {
                if (this._users.Contains(user))
                    return;

                this._users.Remove(user);
            }
        }
 /// <summary>
 /// Returns true if "usr" has mode 'o'|'O'
 /// </summary>
 /// <param name="usr>SimpleUser object to check</param>
 public bool IsOper(SimpleUser usr)
 {
     return (usr.UserMode.HasMode(IRCUserModes.MODE_OP) | usr.UserMode.HasMode(IRCUserModes.MODE_LOCAL_OP));
 }
 /// <summary>
 /// </summary>
 public bool IsMyClient(SimpleUser usr)
 {
     if (usr.UpLink.GetType() == typeof(IRCUserConnection))
         return true;
     return false;
 }
 /// <summary>
 /// </summary>
 public OperData GetOperData(string name, SimpleUser usr)
 {
     throw new NotImplementedException();
 }
 /// <summary>
 ///
 /// </summary>
 private string UserPrefix(SimpleUser usr)
 {
     return (":" + usr.NickName + "!" +
         usr.UserName + "@" + usr.HostName + " ");
 }
        /// <summary>
        ///
        /// </summary>
        public virtual void SendCommand(SimpleUser usr, string command, params string[] args)
        {
            if (usr == null)
                throw new ArgumentNullException("usr");

            this.SendCommand(this.UserPrefix(usr), command, args);
        }
        public virtual void Part(SimpleUser usr, Channel channel, string message)
        {
            if (usr == null)
                throw new ArgumentNullException("usr");

            if (channel == null)
                throw new ArgumentNullException("channel");

            lock (channel)
            {
                if (channel.HasUser(usr))
                {
                    channel.Part(usr, message);
                }
            }
        }
 public virtual void Part(SimpleUser usr, Channel channel)
 {
     this.Part(usr, channel, usr.NickName);
 }
 private void AddUser(SimpleUser usr)
 {
     lock (this._users)
     {
         if (this._users.Contains(usr))
         {
             return;
         }
         this._users.Add(usr);
         this._members.Add(usr.UpLink);
         usr.UpLink.Channels.Add(this.Name, this); // TODO: wird auch von server benutzt um bei einen netspliet schneller zu aggieren
     }
 }
        /*
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="text"></param>
        public virtual void SendChat(IRCConnection sender, string text)
        {// TODO: wenn eine object (Socket) nicht zugreifbar ist --> absturz
            foreach (DictionaryEntry myDE in this._nicks)
            {
                if (((ChannelState)myDE.Value).connection == sender)
                    continue;

                if (sender.IsInChannel(this))
                {
                    IRCConnection connection = ((ChannelState)myDE.Value).connection;
                    connection.SendLine(":" + sender.NickName + // BUGFIX: SendLine
                                    "!~" + connection.ClientName +
                                    "@" + connection.HostName + " " +
                                    "PRIVMSG " + this.Name + " " + text);

                    Console.WriteLine(":" + sender.NickName +
                                    "!~" + connection.ClientName +
                                    "@" + connection.HostName + " " +
                                    "PRIVMSG " + this.Name + " " + text);
                }
                else
                {
                    // send (404):
                }
            }
        }
        */
        public virtual void SendChat(IRCConnection sender, SimpleUser usr, string text)
        {
            if (sender == null)
                throw new ArgumentNullException("sender");

            if (usr == null)
                throw new ArgumentNullException("usr");

            if (this.HasConnection(sender))
            {
                foreach (IRCConnection connection in this._members)
                {
            //					if (myDE.Value == sender)
            //						continue;

            //					IRCUserConnection connection = (IRCUserConnection)myDE.Value;
                    // TODO: SendCommand
            // :[email protected] PRIVMSG #gentoo.de :-kein probelm das tut meine auchohne arts
                    connection.SendLine(":" + usr.NickName + // TODO: usr.SendCommand(); sender findet dann keine verwengung mehr
                                        "!" + usr.UserName +
                                        "@" + usr.HostName + " " +
                                        "PRIVMSG " + this.Name + " " + text);
                    //connection.SendCommamd("Primsg" + this.Name + " " + text);
                }
            }
            else
            {
            //sender.SendLine(404)
            }
        }
        // TODO
        public void RemoveUser(SimpleUser usr, ExitType type)
        {
            if (usr == null)
                throw new ArgumentNullException("usr");

            lock (this._users)
            {
                if (this._users.Contains(usr))
                {
                    this._users.Remove(usr);
                    this._members.Remove(usr.UpLink);
                    usr.UpLink.Channels.Remove(this.Name);
            /* TODO: nachrichten senden
                    switch (type)
                    {
                        case ExitType.Quit:
                        case ExitType.Kick:
                        case ExitType.Part:
                            /*
                            * Server informieren <-- nicht notwendig, sieht Part()
                            *
                    }*/
                }
            }

            if (this.HasMode('P')) // pre-defined channel
                return;

            if (this.MemberCount == 0)
            {
                this._server.RemoveChannel(this);
                this.Dispose();
            }
        }
        // TODO: SimpleUser
        public virtual void Part(SimpleUser usr, string message)
        {
            if (usr == null)
                throw new ArgumentNullException("usr");

            this.RemoveUser(usr, ExitType.Part);
            // TODO: server informieren
            #if false
            //connection.SendLine(":" + connection.NickName +
            //			"!" + connection.UserName +
            //			"@" + connection.HostName + " PART " + this.Name);

            //			if( ! Remove_Client( REMOVE_PART, chan, Client, Origin, Reason, true)) return false;
            //				else return true;
            #endif
        }
 public virtual bool HasUser(SimpleUser usr)
 {
     if (this._users.Contains(usr))
         return true;
     return false;
 }