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": DccChat chat = new DccChat(this, _ExternalIpAdress, e); _DccConnections.Add(chat); ThreadPool.QueueUserWorkItem(new WaitCallback(chat.InitWork)); break; case "SEND": if (e.Data.MessageArray.Length > 6 && (FilterMarker(e.Data.MessageArray[6]) != "T")) { long session = -1; 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 { DccSend send = new DccSend(this, _ExternalIpAdress, e); _DccConnections.Add(send); ThreadPool.QueueUserWorkItem(new WaitCallback(send.InitWork)); } break; case "RESUME": foreach(DccConnection dc in _DccConnections) { if((dc is DccSend) && (((DccSend)dc).TryResume(e))) { return; } } SendMessage(SendType.CtcpReply, e.Data.Nick, "ERRMSG Invalid DCC RESUME"); break; case "ACCEPT": foreach(DccConnection dc in _DccConnections) { if((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) { DccSend send = new DccSend(this, user, _ExternalIpAdress, file, filename, filesize, speed, passive, priority); _DccConnections.Add(send); ThreadPool.QueueUserWorkItem(new WaitCallback(send.InitWork)); RemoveInvalidDccConnections(); }
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": DccChat chat = new DccChat(this, _ExternalIpAdress, e); _DccConnections.Add(chat); ThreadPool.QueueUserWorkItem(new WaitCallback(chat.InitWork)); break; case "SEND": if (e.Data.MessageArray.Length > 6 && (FilterMarker(e.Data.MessageArray[6]) != "T")) { long session = -1; 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 { DccSend send = new DccSend(this, _ExternalIpAdress, e); _DccConnections.Add(send); ThreadPool.QueueUserWorkItem(new WaitCallback(send.InitWork)); } break; case "RESUME": foreach (DccConnection dc in _DccConnections) { if ((dc is DccSend) && (((DccSend)dc).TryResume(e))) { return; } } SendMessage(SendType.CtcpReply, e.Data.Nick, "ERRMSG Invalid DCC RESUME"); break; case "ACCEPT": foreach (DccConnection dc in _DccConnections) { if ((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; } } }