/// <summary> /// Sends a Dcc Send request to the specified target and establishs a DccSendListener with a custom /// timeout to listen for a user in order to start a file transfer. /// </summary> /// <param name="target">The nick of the user who should receive a file.</param> /// <param name="timeout">Specifies how long the listener should wait for an incoming receiver.</param> /// <param name="filename">The name of the file which should be sent.</param> /// <returns>A DccSendClient instance that is supposed to send the corresponding file.</returns> public DccSendClient Send(string target, string filename, TimeSpan timeout, int port) { var user = m_irc.GetUser(target); if (user == null) { user = new IrcUser(m_irc, target); m_irc.OnUserEncountered(user); } var file = new FileInfo(filename); if (!file.Exists) { throw new FileNotFoundException("The file does not exist", filename); } var client = new DccSendClient(this, user, file, timeout, port); m_irc.CommandHandler.DccRequest(target, "SEND {0} {1} {2} {3}", file.Name.Replace(" ", "_"), Util.GetTcpAddress(Util.ExternalAddress), client.Listener.Port, file.Length); return(client); }
private void HandleResume(IrcUser user, string[] args) { try { var port = Convert.ToInt32(args[1]); var pos = Convert.ToInt64(args[2]); DccSendClient client = null; foreach (var clients in transferCons.Values) { foreach (var cli in clients) { client = cli as DccSendClient; if (client != null && client.Listener != null && client.Listener.LocalEndPoint.Port == port) { client.SetPos(pos); break; } } } if (client != null) { m_irc.CommandHandler.DccRequest(user.Nick, string.Format( "ACCEPT \"{0}\" {1} {2}", client.File.Name, port, pos)); } } catch (Exception) { HandleInvalid(user, "RESUME", args); } }
/// <summary> /// Sends a Dcc Send request to the specified target and establishs a DccSendListener with a custom /// timeout to listen for a user in order to start a file transfer. /// </summary> /// <param name="target">The nick of the user who should receive a file.</param> /// <param name="timeout">Specifies how long the listener should wait for an incoming receiver.</param> /// <param name="filename">The name of the file which should be sent.</param> /// <returns>A DccSendClient instance that is supposed to send the corresponding file.</returns> public DccSendClient Send(string target, string filename, TimeSpan timeout, int port) { var user = m_irc.GetUser(target); if (user == null) { user = new IrcUser(m_irc, target); m_irc.OnUserEncountered(user); } var file = new FileInfo(filename); if (!file.Exists) { throw new FileNotFoundException("The file does not exist", filename); } var client = new DccSendClient(this, user, file, timeout, port); m_irc.CommandHandler.DccRequest(target, "SEND {0} {1} {2} {3}", file.Name.Replace(" ", "_"), Util.GetTcpAddress(Util.ExternalAddress), client.Listener.Port, file.Length); return client; }