public static void StartAcceptEvent(PeerSocket peer, XmlRequest xml) { if (AcceptEvent != null) { AcceptEvent(peer, xml); } }
/// Remove file from Accept list and prepare to Receve it public static void InitFile(PeerSocket peer, XmlRequest xml) { FileReceiver fileRecv = LookupFileReceiver(peer, xml); string path = (string)xml.Attributes["name"]; Hashtable peerList = acceptList[peer] as Hashtable; string name = (string)peerList[path]; peerList.Remove(path); acceptList[peer] = peerList; if (fileRecv == null) { fileRecv = new FileReceiver(peer, xml, name); AddFileReceiver(peer, path, fileRecv); } numDownloads++; // Start New File Added if (Added != null) { Added(fileRecv); } }
public static void StartUnknownEvent(PeerSocket peer, XmlRequest xml) { if (UnknownEvent != null) { UnknownEvent(peer, xml); } }
public static void StartGetEvent(PeerSocket peer, XmlRequest xml) { if (GetEvent != null) { GetEvent(peer, xml); } }
/// Send Error public static void Error(PeerSocket peer, string message) { XmlRequest xmlRequest = new XmlRequest(); xmlRequest.FirstTag = "error"; xmlRequest.BodyText = message; peer.Send(xmlRequest.GenerateXml()); }
public static void StartErrorEvent(PeerSocket peer, XmlRequest xml) { if (ErrorEvent != null) { ErrorEvent(peer, xml); } }
/// Get File Part public static void GetFilePart(PeerSocket peer, XmlRequest xml) { FileReceiver fileRecv = LookupFileReceiver(peer, xml); if (fileRecv != null) { fileRecv.Append(xml); // Send Received Part Event if (Received != null) { Received(fileRecv); } } else { string fileName = (string)xml.Attributes["name"]; UserInfo userInfo = peer.Info as UserInfo; string message = "What file is this ?" + "\nUser: "******"\nFileName: " + fileName; throw(new DownloadManagerException(message)); } }
// ============================================ // PRIVATE Methods // ============================================ private void AcceptFileQuestion(PeerSocket peer, XmlRequest xml) { string name = (string) xml.Attributes["name"]; string size = (string) xml.Attributes["size"]; ulong id = ulong.Parse((string) xml.Attributes["id"]); UserInfo userInfo = peer.Info as UserInfo; StringBuilder questionMsg = new StringBuilder(); questionMsg.AppendFormat("Accept File '<b>{0}</b>' ", name); questionMsg.AppendFormat("(Size <b>{0}</b>)\n", FileUtils.GetSizeString(long.Parse(size))); questionMsg.AppendFormat("From User '<b>{0}</b>' ?", userInfo.Name); // Accept Yes/No Dialog bool accept = Base.Dialogs.QuestionDialog("Accept File", questionMsg.ToString()); if (accept == false) return; // Save File Dialog string savePath = FileAlreadyInUse(name); if (savePath == null) return; // Send Accept File Command Debug.Log("Accept File '{0}' From '{1}', Save as '{2}'", userInfo.Name, name, savePath); DownloadManager.Accept(peer, id, name, savePath); Cmd.RequestFile(peer, id); }
/// Create New Login Checker public Login(PeerSocket peer, XmlRequest xml) { // Get UserName string userName = (string)xml.Attributes["name"]; if (userName == null) { return; } // Get SecureAuth bool secureAuth = false; string _secureAuth = (string)xml.Attributes["secure"]; if (_secureAuth != null && _secureAuth == "True") { secureAuth = true; } // Get Magic string magic = (string)xml.Attributes["magic"]; if (secureAuth == true && magic == null) { return; } // Initialize UserInfo this.userInfo = new UserInfo(userName, secureAuth, magic); }
public static void StartSndAbortEvent(PeerSocket peer, XmlRequest xml) { if (SndAbortEvent != null) { SndAbortEvent(peer, xml); } }
public static void StartRecvAbortEvent(PeerSocket peer, XmlRequest xml) { if (RecvAbortEvent != null) { RecvAbortEvent(peer, xml); } }
/// Request File By Path public static void RequestFile(PeerSocket peer, string path) { XmlRequest xmlRequest = new XmlRequest(); xmlRequest.FirstTag = "get"; xmlRequest.Attributes.Add("what", "file"); xmlRequest.Attributes.Add("path", path); peer.Send(xmlRequest.GenerateXml()); }
/// Remove file from Download Manager public static void Remove(PeerSocket peer, XmlRequest xml) { FileReceiver fileRecv = LookupFileReceiver(peer, xml); if (fileRecv != null) { Remove(fileRecv); } }
/// Request File public static void RequestFile(PeerSocket peer, string path) { XmlRequest xmlRequest = new XmlRequest(); xmlRequest.FirstTag = "get"; xmlRequest.BodyText = path; xmlRequest.Attributes.Add("what", "file"); peer.Send(xmlRequest.GenerateXml()); }
/// Request User's Folder public static void RequestFolder(PeerSocket peer, string path) { XmlRequest xmlRequest = new XmlRequest(); xmlRequest.FirstTag = "get"; xmlRequest.Attributes.Add("what", "file-list"); xmlRequest.Attributes.Add("path", path); peer.Send(xmlRequest.GenerateXml()); }
/// Request File By ID public static void RequestFile(PeerSocket peer, ulong id) { XmlRequest xmlRequest = new XmlRequest(); xmlRequest.FirstTag = "get"; xmlRequest.Attributes.Add("what", "file-id"); xmlRequest.Attributes.Add("id", id); peer.Send(xmlRequest.GenerateXml()); }
// Evento Scatenato quando un utente accetta un qualcosa... // Indica al Ricevente di Iniziare ad Inviare... // <accept what='file' name='...' path='...' size='...' /> public void OnAcceptEvent(PeerSocket peer, XmlRequest xml) { Gtk.Application.Invoke(delegate { string what = (string) xml.Attributes["what"]; if (what == "file") { OnAcceptFileEvent(peer, xml); } }); }
/// Send My File List public static void SendFileList(PeerSocket peer, string path) { XmlRequest xmlRequest = new XmlRequest(); xmlRequest.FirstTag = "snd"; xmlRequest.BodyText = GetMyFolder(path); xmlRequest.Attributes.Add("what", "folder-list"); xmlRequest.Attributes.Add("path", path); peer.Send(xmlRequest.GenerateXml()); }
// ============================================ // PUBLIC Methods // ============================================ /// Initialize File public void Init(XmlRequest xml) { Size = long.Parse((string)xml.Attributes["size"]); Name = (string)xml.Attributes["name"]; // Create Null File and Open Binary Stream FileStream stream = FileUtils.CreateNullFile(MyDiskName, Size); binaryWriter = new BinaryWriter(stream); }
/// Create New File Receiver public FileReceiver(PeerSocket peer, XmlRequest xml, string name) { this.peer = peer; this.fileSaved = 0; fileName = (string) xml.Attributes["name"]; fileSize = Int32.Parse((string) xml.Attributes["size"]); // Create File Stream FileStream stream = FileUtils.CreateNullFile(name, fileSize); binaryWriter = new BinaryWriter(stream); }
// ============================================ // PUBLIC Methods // ============================================ /// Add File Part public void Append(XmlRequest xml) { int part = int.Parse((string)xml.Attributes["part"]); byte[] data = Convert.FromBase64String(xml.BodyText); fileSaved += data.Length; // Seek to Offset binaryWriter.Seek((int)(part * FileSender.ChunkSize), SeekOrigin.Begin); binaryWriter.Write(data, 0, data.Length); }
/// Create New File Receiver public FileReceiver(PeerSocket peer, XmlRequest xml, string name) { this.peer = peer; this.fileSaved = 0; fileName = (string)xml.Attributes["name"]; fileSize = Int32.Parse((string)xml.Attributes["size"]); // Create File Stream FileStream stream = FileUtils.CreateNullFile(name, fileSize); binaryWriter = new BinaryWriter(stream); }
// ============================================ // PUBLIC Events // ============================================ // ============================================ // PUBLIC Methods // ============================================ /// Send Login public static void Login(PeerSocket peer, UserInfo userInfo) { XmlRequest xmlRequest = new XmlRequest(); xmlRequest.FirstTag = "login"; xmlRequest.Attributes.Add("name", userInfo.Name); xmlRequest.Attributes.Add("secure", userInfo.SecureAuthentication.ToString()); string magic = Protocol.Login.GenerateMagic(peer); xmlRequest.Attributes.Add("magic", magic); peer.Send(xmlRequest.GenerateXml()); }
// ============================================ // PRIVATE Methods // ============================================ private static void SendFileAbort(PeerSocket peer, string fname, long fsize) { // XmlRequest XmlRequest xmlRequest = new XmlRequest(); xmlRequest.FirstTag = "recv-abort"; xmlRequest.Attributes.Add("what", "file"); xmlRequest.Attributes.Add("name", fname); // Send To Peer peer.Send(xmlRequest.GenerateXml()); }
/// Accept File Request public static void AcceptFile(PeerSocket peer, string path) { string name = Path.GetFileName(path); XmlRequest xmlRequest = new XmlRequest(); xmlRequest.FirstTag = "accept"; xmlRequest.Attributes.Add("what", "file"); xmlRequest.Attributes.Add("path", path); xmlRequest.Attributes.Add("name", name); peer.Send(xmlRequest.GenerateXml()); }
// ============================================ // PRIVATE (Methods) Event Handlers // ============================================ private static FileReceiver LookupFileReceiver(PeerSocket peer, XmlRequest xml) { string fileName = (string)xml.Attributes["name"]; Hashtable peerList = recvFileList[peer] as Hashtable; if (peerList == null) { return(null); } FileReceiver fileReceiver = peerList[fileName] as FileReceiver; return(fileReceiver); }
// ============================================ // PUBLIC STATIC Methods (Commands) // ============================================ /// Send Login public static void Login(PeerSocket peer, UserInfo userInfo) { XmlRequest xmlRequest = new XmlRequest(); xmlRequest.FirstTag = "login"; xmlRequest.Attributes.Add("name", userInfo.Name); xmlRequest.Attributes.Add("secure", userInfo.SecureAuthentication.ToString()); string magic = Protocol.Login.GenerateMagic(peer); xmlRequest.Attributes.Add("magic", magic); peer.Send(xmlRequest.GenerateXml()); }
/// Ask Send File public static void AskSendFile(PeerSocket peer, string path) { FileInfo fileInfo = new FileInfo(path); XmlRequest xmlRequest = new XmlRequest(); xmlRequest.FirstTag = "ask"; xmlRequest.Attributes.Add("what", "file"); xmlRequest.Attributes.Add("path", path); xmlRequest.Attributes.Add("name", fileInfo.Name); xmlRequest.Attributes.Add("size", fileInfo.Length); peer.Send(xmlRequest.GenerateXml()); }
/// Append Data to The File public void AddPart(XmlRequest xml) { try { int part = int.Parse((string)xml.Attributes["part"]); byte[] data = Convert.FromBase64String(xml.BodyText); fileSaved += data.Length; // Seek to Offset & Write Data binaryWriter.Seek((int)(part * FileSender.ChunkSize), SeekOrigin.Begin); binaryWriter.Write(data, 0, data.Length); } catch (Exception e) { Debug.Log("FileReceiver.AddPart(): {0}", e.Message); } }
/// <snd-end what='file' id='10 /> public void SendFileEnd() { // XmlRequest XmlRequest xmlRequest = new XmlRequest(); xmlRequest.FirstTag = "snd-end"; xmlRequest.Attributes.Add("what", "file"); xmlRequest.Attributes.Add("id", Id); // Send To Peer if (Peer != null) { Peer.Send(xmlRequest.GenerateXml()); } }
/// Get User Port public static int Port(UserInfo userInfo) { // Make Url & Request string url = MakeUrl(userInfo, "GetPort.php", null); XmlRequest xml = MakeRequest(url); // Parse Xml Response if (xml.FirstTag == "port") { return(Int32.Parse(xml.BodyText)); } // Request Error throw(new Exception(xml.FirstTag + ": " + xml.BodyText)); }
private void SendFileStart() { // XmlRequest XmlRequest xmlRequest = new XmlRequest(); xmlRequest.FirstTag = "snd-start"; xmlRequest.Attributes.Add("what", "file"); xmlRequest.Attributes.Add("name", this.fileName); xmlRequest.Attributes.Add("size", this.fileSize); // Send To Peer if (this.peer != null) { this.peer.Send(xmlRequest.GenerateXml()); } }
// ============================================ // PUBLIC Methods // ============================================ /// Send Ask Message to User (Do You Want This?) public void Ask() { // XmlRequest XmlRequest xmlRequest = new XmlRequest(); xmlRequest.FirstTag = "ask"; xmlRequest.Attributes.Add("what", "file"); xmlRequest.Attributes.Add("id", Id); xmlRequest.Attributes.Add("size", Size); xmlRequest.Attributes.Add("name", Name); // Send To Peer if (Peer != null) { Peer.Send(xmlRequest.GenerateXml()); } }
/// Create New Login Checker public Login(PeerSocket peer, XmlRequest xml) { // Get UserName string userName = (string) xml.Attributes["name"]; if (userName == null) return; // Get SecureAuth bool secureAuth = false; string _secureAuth = (string) xml.Attributes["secure"]; if (_secureAuth != null && _secureAuth == "True") secureAuth = true; // Get Magic string magic = (string) xml.Attributes["magic"]; if (secureAuth == true && magic == null) return; // Initialize UserInfo this.userInfo = new UserInfo(userName, secureAuth, magic); }
/// Update My Server Status public static void Update(UserInfo userInfo) { // Set Options Hashtable options = new Hashtable(); options.Add("magic", userInfo.Informations["magic"]); // Make Url & Request string url = MakeUrl(userInfo, "Update.php", options); XmlRequest xml = MakeRequest(url); // Parse Xml Response if (xml.FirstTag != "update") { // Request Error throw(new Exception(xml.FirstTag + ": " + xml.BodyText)); } }
// ============================================ // PRIVATE (Methods) Event Handlers // ============================================ private void OnReceived(object sender, PeerEventArgs args) { PeerSocket peer = sender as PeerSocket; // Get Response String and Check if is Valid Xml string xml = peer.GetResponseString(); if (xml == null) { return; } // Remove Response Message peer.ResetResponse(); // Get Xml Commands xml = xml.Trim(); ArrayList xmlCmds = new ArrayList(); lock (peer.Response) { int splitPos = 0; while ((splitPos = xml.IndexOf("><")) >= 0) { // Add Xml Command To Cmds string cmd = xml.Substring(0, splitPos + 1); xmlCmds.Add(cmd); // Remove Splitted Part xml = xml.Remove(0, splitPos + 1); } if (XmlRequest.IsEndedXml(xml) == false) { peer.Response.Insert(0, xml); } else { xmlCmds.Add(xml); } } // Start New Command Parse Thread new CmdParse(peer, xmlCmds); }
public void SendImageThumb(PeerSocket peer, string filePath) { string imgThumb = GenerateImageThumb(filePath); if (imgThumb == null) return; // Generate Xml Request XmlRequest xmlRequest = new XmlRequest(); xmlRequest.FirstTag = "snd"; xmlRequest.BodyText = imgThumb; xmlRequest.Attributes.Add("what", "imgthumb"); xmlRequest.Attributes.Add("path", filePath); peer.Send(xmlRequest.GenerateXml()); }
public void RequestImage(UserInfo userInfo, string filePath) { // Get Peer From UserInfo PeerSocket peer = P2PManager.KnownPeers[userInfo] as PeerSocket; if (peer != null) { // Generate Xml Request XmlRequest xmlRequest = new XmlRequest(); xmlRequest.FirstTag = "get"; xmlRequest.BodyText = filePath; xmlRequest.Attributes.Add("what", "imgthumb"); peer.Send(xmlRequest.GenerateXml()); } else { LoadImage(userInfo, filePath); } }
public void OnSndEvent(PeerSocket peer, XmlRequest xml) { Gtk.Application.Invoke(delegate { string what = (string) xml.Attributes["what"]; if (what == "folder-list") { UserInfo userInfo = peer.Info as UserInfo; FolderViewer folderViewer = notebookViewer.LookupPage(userInfo); folderViewer.Fill((string) xml.Attributes["path"], xml.BodyText); } else if (what == "file") { try { DownloadManager.GetFilePart(peer, xml); } catch (Exception e) { Glue.Dialogs.MessageError("Download File Part", e.Message); } } }); }
public void OnSndStartEvent(PeerSocket peer, XmlRequest xml) { Gtk.Application.Invoke(delegate { string what = (string) xml.Attributes["what"]; if (what == "file") { try { DownloadManager.InitFile(peer, xml); } catch (Exception e) { Glue.Dialogs.MessageError("Start File Download", e.Message); } } }); }
// ============================================ // PRIVATE Methods // ============================================ // ============================================ // PRIVATE Methods // ============================================ private void AcceptFileQuestion(PeerSocket peer, XmlRequest xml) { string name = (string) xml.Attributes["name"]; string path = (string) xml.Attributes["path"]; string size = (string) xml.Attributes["size"]; if (size == null) size = "0"; UserInfo userInfo = peer.Info as UserInfo; StringBuilder questionMsg = new StringBuilder(); questionMsg.AppendFormat("Accept File '<b>{0}</b>' ", name); questionMsg.AppendFormat("(Size <b>{0}</b>)\n", FileUtils.GetSizeString(long.Parse(size))); questionMsg.AppendFormat("From User '<b>{0}</b>' ?", userInfo.Name); // Accept Yes/No Dialog bool accept = Glue.Dialogs.QuestionDialog("Accept File", questionMsg.ToString()); if (accept == false) return; // Save File Dialog string savePath = Glue.Dialogs.SaveFile(Paths.UserSharedDirectory(MyInfo.Name), name); if (savePath == null) return; // Send Accept File Command Debug.Log("Accept File '{0}' From '{1}', Save as '{2}'", userInfo.Name, path, savePath); DownloadManager.AddToAcceptList(peer, path, savePath); CmdManager.AcceptFile(peer, xml); }
private static void SendMessage(PeerSocket peer, string message) { XmlRequest xmlRequest = new XmlRequest(); xmlRequest.FirstTag = "msg"; xmlRequest.BodyText = message; if (peer != null) peer.Send(xmlRequest.GenerateXml()); }
/// <recv-abort what='file' id='10' /> private void OnRecvAbortEvent(PeerSocket peer, XmlRequest xml) { Gtk.Application.Invoke(delegate { string what = (string) xml.Attributes["what"]; if (what == "file") { ulong id = ulong.Parse((string) xml.Attributes["id"]); UploadManager.Abort(peer, id); } }); }
// =================================================== // PRIVATE (Methods) Protocol Event Handler // =================================================== private void OnAcceptFileEvent(PeerSocket peer, XmlRequest xml) { try { string path = (string) xml.Attributes["path"]; UserInfo userInfo = peer.Info as UserInfo; UploadManager.Add(userInfo, path); } catch (Exception e) { Glue.Dialogs.MessageError("Accept File", "Peer Ip: " + peer.GetRemoteIP().ToString() + "\n" + e.Message); } }
public void OnGetEvent(PeerSocket peer, XmlRequest xml) { if (xml.Attributes["what"].Equals("imgthumb")) { SendImageThumb(peer, xml.BodyText); } }
private static void SendError(PeerSocket peer, string error) { XmlRequest xmlRequest = new XmlRequest(); xmlRequest.FirstTag = "msg"; xmlRequest.BodyText = error; xmlRequest.Attributes.Add("type", "error"); if (peer != null) peer.Send(xmlRequest.GenerateXml()); }
private void SendFilePart(byte[] data, uint npart) { // Base64 Convert string b64data = Convert.ToBase64String(data); // XmlRequest XmlRequest xmlRequest = new XmlRequest(); xmlRequest.FirstTag = "snd"; xmlRequest.BodyText = b64data; xmlRequest.Attributes.Add("what", "file"); xmlRequest.Attributes.Add("name", this.fileName); xmlRequest.Attributes.Add("size", this.fileSize); xmlRequest.Attributes.Add("part", npart); // Add md5sum xmlRequest.AddAttributeMd5Sum(); // Send To Peer if (this.peer != null) this.peer.Send(xmlRequest.GenerateXml()); }
// ============================================ // PUBLIC Methods // ============================================ /// Initialize File public void Init(XmlRequest xml) { Size = long.Parse((string) xml.Attributes["size"]); Name = (string) xml.Attributes["name"]; // Create Null File and Open Binary Stream FileStream stream = FileUtils.CreateNullFile(MyDiskName, Size); binaryWriter = new BinaryWriter(stream); }
protected void OnUnknownEvent(PeerSocket peer, XmlRequest xml) { if (xml.FirstTag != "msg") return; Gtk.Application.Invoke(delegate { UserInfo userInfo = peer.Info as UserInfo; string type = (string) xml.Attributes["type"]; if (type == null) { TalkManager.InsertMessage(userInfo, xml.BodyText); } else if (type == "status") { TalkManager.InsertStatus(userInfo, xml.BodyText); } else if (type == "error") { TalkManager.InsertError(userInfo, xml.BodyText); } }); }
private void SendFileEnd(string msgerror) { // XmlRequest XmlRequest xmlRequest = new XmlRequest(); xmlRequest.FirstTag = "snd-end"; if (msgerror != null) xmlRequest.BodyText = "Sending Error: " + msgerror; xmlRequest.Attributes.Add("what", "file"); xmlRequest.Attributes.Add("name", this.fileName); xmlRequest.Attributes.Add("size", this.fileSize); // Send To Peer if (this.peer != null) this.peer.Send(xmlRequest.GenerateXml()); }
private static void SendStatus(PeerSocket peer, string status) { XmlRequest xmlRequest = new XmlRequest(); xmlRequest.FirstTag = "msg"; xmlRequest.BodyText = status; xmlRequest.Attributes.Add("type", "status"); if (peer != null) peer.Send(xmlRequest.GenerateXml()); }
/// <snd what='file' id='10' part='13'>...</snd> private void OnSndEvent(PeerSocket peer, XmlRequest xml) { Gtk.Application.Invoke(delegate { string what = (string) xml.Attributes["what"]; switch (what) { case "file": ulong id = ulong.Parse((string) xml.Attributes["id"]); DownloadManager.GetFilePart(peer, id, xml); break; case "file-list": UserInfo userInfo = peer.Info as UserInfo; FolderViewer folderViewer = notebookViewer.LookupPage(userInfo); folderViewer.Fill((string) xml.Attributes["path"], xml.BodyText); break; } }); }
// ================================================= // PROTECTED (Methods) Protocol Cmds Event Handlers // ================================================= /// <get what='file' id='10' /> private void OnGetEvent(PeerSocket peer, XmlRequest xml) { Gtk.Application.Invoke(delegate { string what = (string) xml.Attributes["what"]; switch (what) { case "file-id": try { ulong id = ulong.Parse((string) xml.Attributes["id"]); UploadManager.Send(peer, id); // TODO: Manage ID Not Found } catch (Exception e) { Base.Dialogs.MessageError("File Not Found", e.Message); } break; case "file": string filePath = (string) xml.Attributes["path"]; filePath = Path.Combine(Paths.UserSharedDirectory(MyInfo.Name), filePath.Substring(1)); UploadManager.Send(peer, filePath); break; case "file-list": string folderPath = (string) xml.Attributes["path"]; Cmd.SendFileList(peer, folderPath); break; } }); }
/// <snd-start what='file' id='10' name='/pippo.txt' size='1024' /> private void OnSndStartEvent(PeerSocket peer, XmlRequest xml) { Gtk.Application.Invoke(delegate { string what = (string) xml.Attributes["what"]; if (what == "file") { ulong id = ulong.Parse((string) xml.Attributes["id"]); DownloadManager.InitDownload(peer, id, xml); } }); }
public void OnSndEvent(PeerSocket peer, XmlRequest xml) { if (xml.Attributes["what"].Equals("imgthumb")) { string path = (string) xml.Attributes["path"]; ReceiveImageThumb((UserInfo) peer.Info, path, xml.BodyText); } }
/// Append Data to The File public void AddPart(XmlRequest xml) { try { int part = int.Parse((string) xml.Attributes["part"]); byte[] data = Convert.FromBase64String(xml.BodyText); fileSaved += data.Length; // Seek to Offset & Write Data binaryWriter.Seek((int)(part * FileSender.ChunkSize), SeekOrigin.Begin); binaryWriter.Write(data, 0, data.Length); } catch (Exception e) { Debug.Log("FileReceiver.AddPart(): {0}", e.Message); } }
private static XmlRequest MakeRequest(string url) { Debug.Log("Web Request: '{0}'", url); // Make Http Request WebRequest request = WebRequest.Create(url); request.Timeout = 5000; if ((proxy = Utils.Proxy.GetConfig()) != null) request.Proxy = proxy; // Wait Http Response WebResponse response = request.GetResponse(); XmlRequest xmlRequest = new XmlRequest(response.GetResponseStream()); xmlRequest.Parse(); response.Close(); return(xmlRequest); }
// ============================================ // PRIVATE Methods // ============================================ /// <recv-abort what='file' id='10' /> /// <recv-abort what='file' id='10'>Error Message</abort> private void AbortRecvFile(string msgerror) { // XmlRequest XmlRequest xmlRequest = new XmlRequest(); xmlRequest.FirstTag = "recv-abort"; if (msgerror != null) xmlRequest.BodyText = "Sending Error: " + msgerror; xmlRequest.Attributes.Add("what", "file"); xmlRequest.Attributes.Add("id", Id); // Send To Peer if (Peer != null) Peer.Send(xmlRequest.GenerateXml()); }
private void SendFileStart() { // XmlRequest XmlRequest xmlRequest = new XmlRequest(); xmlRequest.FirstTag = "snd-start"; xmlRequest.Attributes.Add("what", "file"); xmlRequest.Attributes.Add("name", this.fileName); xmlRequest.Attributes.Add("size", this.fileSize); // Send To Peer if (this.peer != null) this.peer.Send(xmlRequest.GenerateXml()); }