예제 #1
0
        public void TextShouldBeWritable(string text)
        {
            var message = new XMPPMessage {
                Text = text
            };

            Assert.AreEqual(text, message.Text);
        }
예제 #2
0
        public static XMPPMessage toXMPP(Message msg)
        {
            var m = new XMPPMessage();

            m.SetAttributeValue(XNamespace.Get(Namespaces.JabberClient) + "type", "chat");
            m.SetAttributeValue(XNamespace.Get(Namespaces.JabberClient) + "id", msg.MessageID);
            m.SetAttributeValue(XNamespace.Get(Namespaces.JabberClient) + "to", msg.To);
            var body = new XElement(XNamespace.Get(Namespaces.JabberClient) + "body");

            body.Value = msg.Text;
            m.Add(body);
            return(m);
        }
예제 #3
0
 public void Send(string xml, string type = null, string id = null, XMPPMessage del = null)
 {
     if (type != null && del != null)
     {
         if (type == "iq")
         {
             iqMethods.Add(id, del);
         }
     }
     Console.ForegroundColor = ConsoleColor.Red;
     //Console.WriteLine (xml);//TODO:
     Console.ForegroundColor = ConsoleColor.White;
     socket.Send(xml);
 }
예제 #4
0
        private void Socket_MessageReceived(object sender, WebSocket4Net.MessageReceivedEventArgs e)
        {
            Console.ForegroundColor = ConsoleColor.Green;
            //Console.WriteLine (e.Message);//TODO:
            Console.ForegroundColor = ConsoleColor.White;
            XmlDocument doc = new XmlDocument();

            doc.LoadXml(e.Message);
            XmlElement node = (XmlElement)doc.FirstChild;

            if (messageTypes.ContainsKey(node.Name))
            {
                XMPPMessage msg = messageTypes[node.Name];
                if (msg != null)
                {
                    msg(node);
                }
            }
        }
예제 #5
0
 public void Send(string xml,string type=null,string id=null,XMPPMessage del=null)
 {
     if (type != null && del != null) {
         if (type == "iq") {
             iqMethods.Add (id, del);
         }
     }
     Console.ForegroundColor = ConsoleColor.Red;
     //Console.WriteLine (xml);//TODO:
     Console.ForegroundColor = ConsoleColor.White;
     socket.Send (xml);
 }
예제 #6
0
 protected void OnMessage(XMPPMessage e)
 {
     Message(this, e);
 }