private void SendPeerList(PeerSocket peer)
        {
            XmlRequest xml = new XmlRequest();

            xml.FirstTag = "peerlist";
            xml.BodyText = GeneratePeerList();
            peer.Send(xml.GenerateXml());
        }
Beispiel #2
0
        private static void SendMessage(PeerSocket peer, string message)
        {
            XmlRequest xmlRequest = new XmlRequest();

            xmlRequest.FirstTag = "msg";
            xmlRequest.BodyText = message;
            peer.Send(xmlRequest.GenerateXml());
        }
Beispiel #3
0
        /// Send Error
        public static void Error(PeerSocket peer, string message)
        {
            XmlRequest xmlRequest = new XmlRequest();

            xmlRequest.FirstTag = "error";
            xmlRequest.BodyText = message;
            peer.Send(xmlRequest.GenerateXml());
        }
        // ============================================
        // PRIVATE Methods
        // ============================================
        private void RequestPeerList(PeerSocket peer)
        {
            XmlRequest xml = new XmlRequest();

            xml.FirstTag = "get";
            xml.Attributes.Add("what", "peerlist");
            peer.Send(xml.GenerateXml());
        }
Beispiel #5
0
        /// 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());
        }
Beispiel #6
0
        /// 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());
        }
Beispiel #7
0
        /// 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());
        }
Beispiel #8
0
        private static void SendError(PeerSocket peer, string error)
        {
            XmlRequest xmlRequest = new XmlRequest();

            xmlRequest.FirstTag = "msg";
            xmlRequest.BodyText = error;
            xmlRequest.Attributes.Add("type", "error");
            peer.Send(xmlRequest.GenerateXml());
        }
Beispiel #9
0
        private static void SendStatus(PeerSocket peer, string status)
        {
            XmlRequest xmlRequest = new XmlRequest();

            xmlRequest.FirstTag = "msg";
            xmlRequest.BodyText = status;
            xmlRequest.Attributes.Add("type", "status");
            peer.Send(xmlRequest.GenerateXml());
        }
Beispiel #10
0
        /// 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());
        }
Beispiel #11
0
        // ============================================
        // 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());
        }
Beispiel #12
0
        /// 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());
        }
Beispiel #13
0
        /// 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());
        }
Beispiel #14
0
        // ============================================
        // 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());
        }
        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);
            }
        }
Beispiel #17
0
 /// Accept File
 public static void AcceptFile(PeerSocket peer, XmlRequest xmlAsk)
 {
     xmlAsk.FirstTag = "accept";
     peer.Send(xmlAsk.GenerateXml());
 }