将成员添加到openfire服务器

时间:2014-09-10 09:41:17

标签: ios xmpp openfire

我在mycchat应用程序中使用openfirexmpp框架。我正在使用

XMPPJID *newBuddy = [XMPPJID jidWithString:@"test@localhost"];
[self.xmppRoster addUser:newBuddy withNickname:@"user1"];

用于添加新成员但新成员未添加到server。 在setupStream方法代码中:

 xmppRosterStorage = [[XMPPRosterCoreDataStorage alloc] init];
 xmppRosterStorage = [[XMPPRosterCoreDataStorage alloc] initWithInMemoryStore];

xmppRoster = [[XMPPRoster alloc] initWithRosterStorage:xmppRosterStorage];
xmppRoster = [[XMPPRoster alloc] initWithRosterStorage:xmppRosterStorage
                                              dispatchQueue:dispatch_get_main_queue()];
[xmppRoster addDelegate:self delegateQueue:dispatch_get_main_queue()];
xmppRoster.autoFetchRoster = YES;
xmppRoster.autoAcceptKnownPresenceSubscriptionRequests = YES;

如何添加会员?

1 个答案:

答案 0 :(得分:1)

@property (nonatomic, readonly) XMPPStream *xmppStream;    
@property (nonatomic, readonly) XMPPRoster *xmppRoster;
@property (nonatomic, readonly) XMPPRosterMemoryStorage *xmppRosterStorage;

setupStream方法设置中XMPPStreamXMPPRoaster

_xmppStream = [[XMPPStream alloc]init];
_xmppStream.enableBackgroundingOnSocket = YES;
_xmppRosterStorage = [[XMPPRosterMemoryStorage alloc] init];
_xmppRoster = [[XMPPRoster alloc] initWithRosterStorage:_xmppRosterStorage];
[_xmppRoster activate:_xmppStream];
[_xmppRoster  addDelegate:self delegateQueue:dispatch_get_main_queue()];

添加新的contact

[_xmppRoster addUser:jid withNickname:nickName];

接收方接受后,新联系人将反映在您的烘焙列表中