private void CtcpDccDelegate(CtcpEventArgs e) { if (e.Data.MessageArray.Length < 2) { SendMessage(SendType.CtcpReply, e.Data.Nick, "ERRMSG DCC missing parameters"); } else { switch (e.Data.MessageArray[1]) { case "CHAT": var chat = new DccChat(this, ExternalIpAdress, e); dccConnections.Add(chat); ThreadPool.QueueUserWorkItem(chat.InitWork); break; case "SEND": if (e.Data.MessageArray.Length > 6 && (FilterMarker(e.Data.MessageArray[6]) != "T")) { long session; long.TryParse(FilterMarker(e.Data.MessageArray[6]), out session); foreach (DccConnection dc in dccConnections) { if (dc.IsSession(session)) { ((DccSend)dc).SetRemote(e); ((DccSend)dc).AcceptRequest(null, 0); return; } } SendMessage(SendType.CtcpReply, e.Data.Nick, "ERRMSG Invalid passive DCC"); } else { var send = new DccSend(this, ExternalIpAdress, e); dccConnections.Add(send); ThreadPool.QueueUserWorkItem(send.InitWork); } break; case "RESUME": if (dccConnections.Any(dc => (dc is DccSend) && (((DccSend)dc).TryResume(e)))) { return; } SendMessage(SendType.CtcpReply, e.Data.Nick, "ERRMSG Invalid DCC RESUME"); break; case "ACCEPT": if (dccConnections.Any(dc => (dc is DccSend) && (((DccSend)dc).TryAccept(e)))) { return; } SendMessage(SendType.CtcpReply, e.Data.Nick, "ERRMSG Invalid DCC ACCEPT"); break; case "XMIT": SendMessage(SendType.CtcpReply, e.Data.Nick, "ERRMSG DCC XMIT not implemented"); break; default: SendMessage(SendType.CtcpReply, e.Data.Nick, "ERRMSG DCC " + e.CtcpParameter + " unavailable"); break; } } }
/// <summary> /// Send any Stream, full flexibility in Dcc Connection Negotiation /// </summary> /// <param name="user">Destination of the File (no channel)</param> /// <param name="file">You can send any stream here</param> /// <param name="filename">give a filename for the remote User</param> /// <param name="filesize">give the length of the stream</param> /// <param name="speed">What ACK Managment should be used</param> /// <param name="passive">Passive DCC</param> /// <param name="priority">Non Dcc Message Priority for Negotiation</param> public void SendFile(string user, Stream file, string filename, long filesize, DccSpeed speed, bool passive, Priority priority) { var send = new DccSend(this, user, ExternalIpAdress, file, filename, filesize, speed, passive, priority); dccConnections.Add(send); ThreadPool.QueueUserWorkItem(send.InitWork); RemoveInvalidDccConnections(); }