/// <summary>
 /// Constructor of a DCC Chat for a Incoming DCC Chat Request
 /// </summary>
 /// <param name="irc">IrcFeature Class</param>
 /// <param name="externalIpAdress">Our externally reachable IP Adress</param>
 /// <param name="e">The Ctcp Event which initiated this constructor</param>
 internal DccChat(IrcFeatures irc, IPAddress externalIpAdress, CtcpEventArgs e)
 {
     Irc = irc;
     ExternalIPAdress = externalIpAdress;
     User             = e.Data.Nick;
     if (e.Data.MessageArray.Length > 4)
     {
         bool okIP = Int64.TryParse(e.Data.MessageArray[3], out long ip);
         bool okPo = Int32.TryParse(FilterMarker(e.Data.MessageArray[4]), out int port);  // port 0 = passive
         if ((e.Data.MessageArray[2] == "chat") && okIP && okPo)
         {
             RemoteEndPoint = new IPEndPoint(IPAddress.Parse(DccIntToHost(ip)), port);
             if (e.Data.MessageArray.Length > 5 && e.Data.MessageArray[5] != "T")
             {
                 AcceptRequest();    // Since we initated the Request, we accept DCC
                 return;             // No OnDccChatRequestEvent Event! (we know that we want a connection)
             }
             DccChatRequestEvent(new DccEventArgs(this));
             return;
         }
         else
         {
             irc.SendMessage(SendType.CtcpReply, e.Data.Nick, "ERRMSG DCC Chat Parameter Error");
         }
     }
     else
     {
         irc.SendMessage(SendType.CtcpReply, e.Data.Nick, "ERRMSG DCC Chat not enough parameters");
     }
     isValid = false;
 }
        internal DccSend(IrcFeatures irc, IPAddress externalIpAdress, CtcpEventArgs e)
        {
            /* Remote Request */
            Irc          = irc;
            _DirectionUp = false;
            User         = e.Data.Nick;

            if (e.Data.MessageArray.Length > 4)
            {
                long filesize = 0;
                if (e.Data.MessageArray.Length > 5)
                {
                    bool okFs = Int64.TryParse(FilterMarker(e.Data.MessageArray[5]), out filesize);
                    _Filesize = filesize;
                    _Filename = e.Data.MessageArray[2].Trim('"');
                }

                if (Int64.TryParse(e.Data.MessageArray[3], out long ip) && Int32.TryParse(e.Data.MessageArray[4], out int port)) // port 0 = passive
                {
                    RemoteEndPoint = new IPEndPoint(IPAddress.Parse(DccIntToHost(ip)), port);
                    DccSendRequestEvent(new DccSendRequestEventArgs(this, e.Data.MessageArray[2], filesize));
                    return;
                }
                irc.SendMessage(SendType.CtcpReply, e.Data.Nick, "ERRMSG DCC Send Parameter Error");
            }
            else
            {
                irc.SendMessage(SendType.CtcpReply, e.Data.Nick, "ERRMSG DCC Send not enough parameters");
            }
        }
        /// <summary>
        /// Constructor of DCC CHat for local DCC Chat Request to a certain user.
        /// </summary>
        /// <param name="irc">IrcFeature Class</param>
        /// <param name="user">Chat Destination (channels are no valid targets)</param>
        /// <param name="externalIpAdress">Our externally reachable IP Adress (can be anything if passive)</param>
        /// <param name="passive">if you have no reachable ports!</param>
        /// <param name="priority">Non DCC Message Priority</param>
        internal DccChat(IrcFeatures irc, string user, IPAddress externalIpAdress, bool passive, Priority priority)
        {
            Irc = irc;
            ExternalIPAdress = externalIpAdress;
            User             = user;

            if (passive)
            {
                irc.SendMessage(SendType.CtcpRequest, user, "DCC CHAT chat " + HostToDccInt(externalIpAdress).ToString() + " 0 " + SessionId, priority);
                Disconnect();
            }
            else
            {
                DccServer = new TcpListener(new IPEndPoint(IPAddress.Any, 0));
                DccServer.Start();
                LocalEndPoint = (IPEndPoint)DccServer.LocalEndpoint;
                irc.SendMessage(SendType.CtcpRequest, user, "DCC CHAT chat " + HostToDccInt(externalIpAdress).ToString() + " " + LocalEndPoint.Port, priority);
            }
        }
        internal DccSend(IrcFeatures irc, string user, IPAddress externalIpAdress, Stream file, string filename, long filesize, DccSpeed speed, bool passive, Priority priority)
        {
            Irc          = irc;
            _DirectionUp = true;
            _File        = file;
            _Filesize    = filesize;
            _Filename    = filename;
            _Speed       = speed;
            User         = user;

            if (passive)
            {
                irc.SendMessage(SendType.CtcpRequest, user, "DCC SEND \"" + filename + "\" " + HostToDccInt(externalIpAdress).ToString() + " 0 " + filesize + " " + SessionId, priority);
            }
            else
            {
                DccServer = new TcpListener(new IPEndPoint(IPAddress.Any, 0));
                DccServer.Start();
                LocalEndPoint = (IPEndPoint)DccServer.LocalEndpoint;
                irc.SendMessage(SendType.CtcpRequest, user, "DCC SEND \"" + filename + "\" " + HostToDccInt(externalIpAdress).ToString() + " " + LocalEndPoint.Port + " " + filesize, priority);
            }
        }