如何使用XMPP Framework发送消息 [英] How to send message using XMPP Framework

查看:201
本文介绍了如何使用XMPP Framework发送消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用iPhone中的XMPP框架创建聊天应用程序.我可以收到消息,但无法发送消息.有人可以给我解决方案吗?

I am creating a chat application using XMPP Framework in iphone. i could get received messages but i am not able to send a message. can any one give me solution for this??

推荐答案

- (void)sendMessage:(NSString *)msgContent
{

    NSString *messageStr = textField.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:[jid full]];
        [message addChild:body];

        [xmppStream sendElement:message];



    }
}

在您的chatViewcontroller中使用上面的代码..对我来说很好.

use the above code in you chatViewcontroller ..it is working fine for me.

这篇关于如何使用XMPP Framework发送消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆