繁体   English   中英

如何使用xmpp openfire发送输入通知

[英]how to send typing notification using xmpp openfire

我正在开发聊天应用程序我想发送收件人“正在打字”当我输入消息时,任何人都知道如何使用xmpp框架和打开火作为服务器。

下面是我的代码

-(void)sendChatStateNotification: (NSString *)strState
{
     NSXMLElement *message = [NSXMLElement elementWithName:@"message"];
     NSXMLElement *chatStatus=[NSXMLElement elementWithName:strState xmlns:xmlns_chatstates];
    [message addAttributeWithName:@"type" stringValue:@"chat"];
    [message addAttributeWithName:@"to" stringValue:chatWithUser];
    [message addChild:chatStatus];
}

-(void)textViewDidChange:(UITextView *)textView
{
    [self sendChatStateNotification:@"composing"];
}

我仍然没有收到通知

用于发送打字状态

NSXMLElement *message = [NSXMLElement elementWithName:@"message"];
[message addAttributeWithName:@"type" stringValue:@"chat"];
[message addAttributeWithName:@"to" stringValue: toID];

NSXMLElement *composing = [NSXMLElement elementWithName:@"composing"];
[composing addAttributeWithName:@"xmlns" stringValue:@"http://jabber.org/protocol/chatstates"];

[message addChild:composing];

[xmppStream sendElement:message];

在接收方

if ([message hasComposingChatState] == YES)

检查此情况并使用正确的打字指示。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM