/// <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(new WaitCallback(send.InitWork)); RemoveInvalidDccConnections(); }
private async Task CtcpFingerDelegate(CtcpEventArgs e) => await SendMessage(SendType.CtcpReply, e.Data.Nick, "FINGER Don't touch little Helga there! ");//SendMessage(SendType.CtcpReply, e.Data.Nick, "FINGER " + this.Realname + " (" + this.Email + ") Idle " + this.Idle + " seconds (" + ((string.IsNullOrEmpty(this.Reason))?this.Reason:"-") + ") " ); private async Task CtcpDccDelegate(CtcpEventArgs e) { if (e.Data.MessageArray.Length < 2) { await 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(new WaitCallback(chat.InitWork)); break; case "SEND": if (e.Data.MessageArray.Length > 6 && (FilterMarker(e.Data.MessageArray[6]) != "T")) { if (!Int64.TryParse(FilterMarker(e.Data.MessageArray[6]), out long session)) { break; } foreach (DccConnection dc in _DccConnections) { if (dc.SessionId == session) { ((DccSend)dc).SetRemote(e); ((DccSend)dc).AcceptRequest(null, 0); return; } } await SendMessage(SendType.CtcpReply, e.Data.Nick, "ERRMSG Invalid passive DCC"); } else { var 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 dcs && dcs.TryResume(e)) { return; } } await SendMessage(SendType.CtcpReply, e.Data.Nick, "ERRMSG Invalid DCC RESUME"); break; case "ACCEPT": foreach (DccConnection dc in _DccConnections) { if (dc is DccSend dcs && dcs.TryAccept(e)) { return; } } await SendMessage(SendType.CtcpReply, e.Data.Nick, "ERRMSG Invalid DCC ACCEPT"); break; case "XMIT": await SendMessage(SendType.CtcpReply, e.Data.Nick, "ERRMSG DCC XMIT not implemented"); break; default: await SendMessage(SendType.CtcpReply, e.Data.Nick, "ERRMSG DCC " + e.CtcpParameter + " unavailable"); break; } } }