gpt4 book ai didi

iOS XMPPFramework 不发送状态

转载 作者:行者123 更新时间:2023-11-29 10:39:58 26 4
gpt4 key购买 nike

我的 xmpp 流连接成功,在回调中我尝试发送用户的存在。但是,我不断收到此错误:Error Domain=XMPPStreamErrorDomain Code=1“操作无法完成。(XMPPStreamErrorDomain 错误 1.)”

我的连接方法:

- (void)connect {
NSString *username = @"masa060295@jabber.web.id";
self.password = @"test123";

[self.xmppStream setMyJID:[XMPPJID jidWithString:username]];

NSError *error = nil;
if (![self.xmppStream connectWithTimeout:XMPPStreamTimeoutNone error:&error])
{
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Error"
message:[NSString stringWithFormat:@"Can't connect to server %@", [error localizedDescription]]
delegate:nil
cancelButtonTitle:@"Ok"
otherButtonTitles:nil];
[alertView show];
}
}

我的回调:

- (void)xmppStreamDidConnect:(XMPPStream *)sender {
NSError *error = nil;

NSLog(@"%hhd", [self.xmppStream isConnected]);

if (![self.xmppStream authenticateWithPassword:self.password error:&error]) {
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Error"
message:[NSString stringWithFormat:@"Can't authenticate %@", [error localizedDescription]]
delegate:nil
cancelButtonTitle:@"Ok"
otherButtonTitles:nil];
[alertView show];
}

XMPPPresence *presence = [XMPPPresence presence];
NSXMLElement *priority = [NSXMLElement elementWithName:@"priority" numberValue:[NSNumber numberWithInt:127]];
[presence addChild:priority];

[self.xmppStream sendElement:presence];
}

有什么想法吗?

最佳答案

您应该在身份验证完成后发送出席信息。在这个回调中做:

 - (void)xmppStreamDidAuthenticate:(XMPPStream *)sender
{
XMPPPresence *presence = [XMPPPresence presence]; // type="available" is implicit

[sender sendElement:presence];
}

关于iOS XMPPFramework 不发送状态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25053969/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com