apophis.SharpIRC.IrcFeatures.DccSend.AcceptRequest C# (CSharp) Method

AcceptRequest() public method

With this methode you can accept a DCC SEND Request you got from another User
public AcceptRequest ( Stream file, long offset ) : bool
file Stream Any Stream you want use as a file, if you use offset it should be Seekable
offset long Offset to start a Resume Request for the rest of a file
return bool
        public bool AcceptRequest(Stream file, long offset)
        {
            if (IsConnected)
                return false;
            try
            {
                if (file != null)
                    this.file = file;
                if (RemoteEndPoint.Port == 0)
                {
                    DccServer = new TcpListener(new IPEndPoint(IPAddress.Any, 0));
                    DccServer.Start();
                    LocalEndPoint = (IPEndPoint)DccServer.LocalEndpoint;
                    Irc.SendMessage(SendType.CtcpRequest, User, "DCC SEND \"" + filename + "\" " + HostToDccInt(ExternalIPAdress) + " " + LocalEndPoint.Port + " " + filesize);
                }
                else
                {
                    if (offset == 0)
                    {
                        Connection = new TcpClient();
                        Connection.Connect(RemoteEndPoint);
                        IsConnected = true;
                    }
                    else
                    {
                        if (this.file.CanSeek)
                        {
                            this.file.Seek(offset, SeekOrigin.Begin);
                            sentBytes = offset;
                            Irc.SendMessage(SendType.CtcpRequest, User, "DCC RESUME \"" + filename + "\" " + RemoteEndPoint.Port + " " + offset);
                        }
                        else
                        {
                            /* Resume of a file which is not seekable : I dont care, its your filestream! */
                            sentBytes = offset;
                            Irc.SendMessage(SendType.CtcpRequest, User, "DCC RESUME \"" + filename + "\" " + RemoteEndPoint.Port + " " + offset);
                        }
                    }
                }
                return true;
            }
            catch (Exception)
            {
                IsValid = false;
                IsConnected = false;
                return false;
            }
        }