XMPPFramework - How to Create Message / Conversation Thread

Viewed 3566

I am working on the iOS chat client by using XMPPFramework ( https://github.com/robbiehanson/XMPPFramework ), can anyone please help me with the chat and message. I use Spark ( http://www.igniterealtime.org/projects/spark/index.jsp ) to test my iOS chat client.

I find out that message XML format send by Spark in the Openfire server log is following:

<message id="nBT3N-161" 
         to="aaa@demo.com/7beebb67" 
         from="bbb@demo.com/Spark 2.6.3" 
         type="chat">
    <body>testing message ...</body>
    <thread>FIoMFD</thread>
    <x xmlns="jabber:x:event"><offline/><composing/></x>
</message> 

Message in the XML format has id :

id="nBT3N-161"

and thread id :

<thread>FIoMFD</thread>

and other info :

<x xmlns="jabber:x:event"><offline/><composing/></x>

But, .. when I use XMPPSteam to send message, the message XML format in the Openfire log is following :

<message type="chat" 
         to="bbb@demo.com/Spark 2.6.3" 
         from="aaa@demo.com/7beebb67">
    <body>tttttttttttttttt</body>
</message>

the message XML format does not include the message id, thread id and xmlns information. My code is following :

- (IBAction)didSendingMessage:(id)sender
{
    NSString *messageStr = self.messageTextField.text;
    if([messageStr length] > 0) {
        NSXMLElement *body = [NSXMLElement elementWithName:@"body"];
        [body setStringValue:messageStr];

        NSXMLElement *message = [NSXMLElement elementWithName:@"message"];
        [message addAttributeWithName:@"type" stringValue:@"chat"];
        [message addAttributeWithName:@"to" stringValue:@"bbb@demo.com/Spark 2.6.3"];
        [message addChild:body];

        [imManager.xmppStream sendElement:message];
        self.messageTextField.text = @"";

       [self.tView reloadData];
    }
}

Does I miss something or did something wrong? How do I generate those information ( ex: message id, thread, xmlns .. ) in the message ?

Or how do I create a message threading or conversation thread ?

Does XMPPFramework has something like ChatManager to createChat in the asmack (https://github.com/Flowdalic/asmack) ?

Thanks

1 Answers
Related