Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 在XMPP框架中为ejabberd快速重新连接和推送模式处理一个扩展_Objective C_Ejabberd_Xmppframework - Fatal编程技术网

Objective c 在XMPP框架中为ejabberd快速重新连接和推送模式处理一个扩展

Objective c 在XMPP框架中为ejabberd快速重新连接和推送模式处理一个扩展,objective-c,ejabberd,xmppframework,Objective C,Ejabberd,Xmppframework,我很难使用为ejabberd开发的名为ProcessOne的XMPPFramework扩展 我正在尝试使用ProcessOne扩展实现快速重新连接和推送模式 // Process One Fast Reconnect & Push Standby Mode // xmppProcessOne = [[XMPPProcessOne alloc] initWithDispatchQueue:dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_

我很难使用为ejabberd开发的名为ProcessOne的XMPPFramework扩展

我正在尝试使用ProcessOne扩展实现快速重新连接和推送模式

// Process One Fast Reconnect & Push Standby Mode //

xmppProcessOne = [[XMPPProcessOne alloc] initWithDispatchQueue:dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0)];
[xmppProcessOne addDelegate:self delegateQueue:dispatch_get_main_queue()];
xmppProcessOne.pushConfiguration = [self setPushconfiguration];
[xmppProcessOne activate:_xmppStream];
根据ejabberd文档,我必须在确认流特征后发送重新绑定数据包。
在XMPPRebindAuthentication的实现下,此扩展中有一个可用的方法。我无法理解如何调用此方法。

我认为支持XMPPFramework中Extensions/ProcessOne会话重新绑定的代码不完整,无法正常工作

下面是我在XMPPFramework上提出的一个补丁,它应该可以工作:

至少我可以使用下面的示例客户端从那里进行重新绑定:

  • AppDelegate.h
//
//AppDelegate.h
//
//米卡·雷蒙德于2016年3月7日创作。
//
#进口
#进口
#进口
#进口
@接口AppDelegate:UIResponder
@属性(强,非原子)UIWindow*window;
/*XMPP相关属性*/
@属性(非原子,强)XMPPStream*XMPPStream;
@属性(非原子,强)XMPPRoster*XMPPRoster;
@属性(非原子,强)XMPPProcessOne*XMPPProcessOne;
@属性(非原子,强)XMPPRosterCoreDataStorage*xmppRosterStorage;
@结束
  • AppDelegate.m
//
//AppDelegate.m
//
//米卡·雷蒙德于2016年3月7日创作。
//
#导入“AppDelegate.h”
#导入“DDLog.h”
#导入“DDTTYLogger.h”
#导入“XMPPLogging.h”
@接口AppDelegate()
-(void)流;
-(BOOL)连接;
@结束
@实现AppDelegate
静态NSString*常量kMyJid=@”test@example.net";
静态NSString*const kMyPass=@“passw0rd”;
-(BOOL)应用程序:(UIApplication*)应用程序使用选项完成启动:(NSDictionary*)启动选项{
//记录所有XMPP流量以进行调试
[DDLog addLogger:[DDTTYLogger sharedInstance]带有日志级别:XMPP_LOG_FLAG_SEND_RECV];
[自动设置流];
返回YES;
}
-(无效)应用程序将重新签名:(UIApplication*)应用程序{
}
-(无效)应用程序标识符背景:(UIApplication*)应用程序{
}
-(无效)应用程序将进入前台:(UIApplication*)应用程序{
}
-(无效)应用IDBECOMEACTIVE:(UIApplication*)应用{
[自我连接];
}
-(无效)申请将终止:(UIApplication*)申请{
}
#pragma标记==设置XMPP参数==
-(无效)设置流{
_xmppStream=[xmppStream new];
_xmppRosterStorage=[XMPPRosterCoreDataStorage new];
_xmppRoster=[[xmppRoster alloc]initWithRosterStorage:_xmppRosterStorage];
[_xmppRoster激活:_xmppStream];
[\u xmppStream addDelegate:self delegateQueue:dispatch_get_main_queue()];
[\u xmppStream addDelegate:self.xmppProcessOne delegateQueue:dispatch\u get\u main\u queue()];
[\u xmppRoster addDelegate:self delegateQueue:dispatch_get_main_queue()];
[\u xmppStream setMyJID:[XMPPJID jidWithString:kMyJid]];
_xmppProcessOne=[[xmppProcessOne alloc]initWithDispatchQueue:dispatch_get_main_queue()];
//TODO:生成默认推送配置的方法
NSXMLElement*pushConfiguration=[XMPPProcessOne pushConfigurationContainer];
[pushConfiguration addChild:[XMPPProcessOne keepaliveWithMax:30]];//秒
[pushConfiguration addChild:[XMPPProcessOne sessionWithDuration:300]];//秒
_xmppProcessOne.pushConfiguration=pushConfiguration;
[\u xmppProcessOne addDelegate:self delegateQueue:dispatch_get_main_queue()];
[_xmppProcessOne激活:self.xmppStream];
}
#pragma标记==XMPP委托==
-(无效)xmppstreamdisconnect:(XMPPStream*)发送方{
if([self.xmppStream supportsRebind]&&self.xmppProcessOne.savedSessionJID!=nil){
n错误*错误=nil;
_xmppRoster.autoFetchRoster=否;
if(![[self-xmppStream]重新绑定会话:self.xmppProcessOne.savedSessionID-forJID:self.xmppProcessOne.savedSessionJID-withError:&error]){
NSLog(@“无法成功发送会话重新绑定:%@”,错误);
}
}否则{
n错误*错误=nil;
_xmppRoster.autoFetchRoster=是;
if(![[self-xmppStream]authenticateWithPassword:kMyPass错误:&error]){
NSLog(@“无法发送标准密码身份验证信息:%@”,错误);
}
}
}
//重新绑定失败,请尝试标准身份验证
-(void)xmppStream:(xmppStream*)发送方runFallbackAuthentication:(NSXMLElement*)错误{
NSLog(@“重新绑定失败:%@”,错误);
N错误*错误2=零;
_xmppRoster.autoFetchRoster=是;
如果(![[self-xmppStream]authenticateWithPassword:kMyPass错误:&error2]){
NSLog(@“未验证%@”,错误2);
}
}
-(无效)xmppStream:(xmppStream*)发送方未验证:(NSXMLElement*)错误{
NSLog(@“身份验证失败:%@”,错误);
}
-(无效)xmppstreamdisauthenticate:(XMPPStream*)发送方{
NSLog(@“身份验证成功”);
[[self-xmppStream]sendElement:[XMPPPresence]];
}
/*启动到XMPP服务器的TCP连接*/
-(BOOL)连接{
如果(!self.xmppStream.isConnected){
如果(![self.xmppStream已断开]){
返回YES;
}
n错误*错误=nil;
if(![self.xmppStream connectWithTimeout:XMPPStreamTimeoutNone错误:&错误]){
NSLog(@“连接到XMPP服务器时出错”);
}否则{
NSLog(@“已成功连接”);
}
返回YES;
}否则{
返回YES;
}
}
@结束

我认为在XMPPFramework中支持Extensions/ProcessOne会话重新绑定的代码不完整,不能按原样工作

下面是我在XMPPFramework上提出的一个补丁,它应该可以工作:

至少我可以使用下面的示例客户端从那里进行重新绑定:

  • AppDelegate.h
//
//AppDelegate.h
//
//米卡·雷蒙德于2016年3月7日创作。
//
#进口
#进口
#进口
#进口
@接口AppDelegate:UIResponder
@属性(强,非原子)UIWindow*window;
/*