真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

ios開(kāi)發(fā)xmpp教程的簡(jiǎn)單介紹

ios開(kāi)發(fā) 用xmpp做即時(shí)通訊怎么與后臺(tái)連接

即時(shí)通訊肯定少不了通訊協(xié)議,在ios開(kāi)發(fā)中基本上都使用基于XMPP 的協(xié)議來(lái)做即時(shí)通訊。在oc下有封裝好的XMPP協(xié)議庫(kù),你在開(kāi)發(fā)時(shí)可以調(diào)用XMPP的API來(lái)進(jìn)行開(kāi)發(fā)。通訊的服務(wù)器可以用ejabberd來(lái)搭建。知道的就這些了

創(chuàng)新互聯(lián)專(zhuān)業(yè)成都網(wǎng)站設(shè)計(jì)、成都網(wǎng)站制作、外貿(mào)網(wǎng)站建設(shè),集網(wǎng)站策劃、網(wǎng)站設(shè)計(jì)、網(wǎng)站制作于一體,網(wǎng)站seo、網(wǎng)站優(yōu)化、網(wǎng)站營(yíng)銷(xiāo)、軟文營(yíng)銷(xiāo)等專(zhuān)業(yè)人才根據(jù)搜索規(guī)律編程設(shè)計(jì),讓網(wǎng)站在運(yùn)行后,在搜索中有好的表現(xiàn),專(zhuān)業(yè)設(shè)計(jì)制作為您帶來(lái)效益的網(wǎng)站!讓網(wǎng)站建設(shè)為您創(chuàng)造效益。

[img]

iOS怎么搭建xmpp聊天

iOS 搭建xmpp聊天的具體步驟如下:

聊天室

[cpp] view plain copy

print?

//初始化聊天室

XMPPJID *roomJID = [XMPPJID jidWithString:ROOM_JID];

xmppRoom = [[XMPPRoom alloc] initWithRoomStorage:self jid:roomJID];

[xmppRoom activate:xmppStream];

[xmppRoom addDelegate:self delegateQueue:dispatch_get_main_queue()];

[cpp] view plain copy

print?

//創(chuàng)建聊天室成功

- (void)xmppRoomDidCreate:(XMPPRoom *)sender

{

DDLogInfo(@"%@: %@", THIS_FILE, THIS_METHOD);

}

[cpp] view plain copy

print?

//加入聊天室,使用昵稱(chēng)

[xmppRoom joinRoomUsingNickname:@"quack" history:nil];

[cpp] view plain copy

print?

//獲取聊天室信息

- (void)xmppRoomDidJoin:(XMPPRoom *)sender

{

[xmppRoom fetchConfigurationForm];

[xmppRoom fetchBanList];

[xmppRoom fetchMembersList];

[xmppRoom fetchModeratorsList];

}

如果房間存在,會(huì)調(diào)用委托

[cpp] view plain copy

print?

// 收到禁止名單列表

- (void)xmppRoom:(XMPPRoom *)sender didFetchBanList:(NSArray *)items;

// 收到好友名單列表

- (void)xmppRoom:(XMPPRoom *)sender didFetchMembersList:(NSArray *)items;

// 收到主持人名單列表

- (void)xmppRoom:(XMPPRoom *)sender didFetchModeratorsList:(NSArray *)items;

房間不存在,調(diào)用委托

[cpp] view plain copy

print?

- (void)xmppRoom:(XMPPRoom *)sender didNotFetchBanList:(XMPPIQ *)iqError;

- (void)xmppRoom:(XMPPRoom *)sender didNotFetchMembersList:(XMPPIQ *)iqError;

- (void)xmppRoom:(XMPPRoom *)sender didNotFetchModeratorsList:(XMPPIQ *)iqError;

離開(kāi)房間

[cpp] view plain copy

print?

[xmppRoom deactivate:xmppStream];

[cpp] view plain copy

print?

//離開(kāi)聊天室

- (void)xmppRoomDidLeave:(XMPPRoom *)sender

{

DDLogVerbose(@"%@: %@", THIS_FILE, THIS_METHOD);

}

其他代理

[cpp] view plain copy

print?

//新人加入群聊

- (void)xmppRoom:(XMPPRoom *)sender occupantDidJoin:(XMPPJID *)occupantJID

{

DDLogVerbose(@"%@: %@", THIS_FILE, THIS_METHOD);

}

//有人退出群聊

- (void)xmppRoom:(XMPPRoom *)sender occupantDidLeave:(XMPPJID *)occupantJID

{

DDLogVerbose(@"%@: %@", THIS_FILE, THIS_METHOD);

}

//有人在群里發(fā)言

- (void)xmppRoom:(XMPPRoom *)sender didReceiveMessage:(XMPPMessage *)message fromOccupant:(XMPPJID *)occupantJID

{

DDLogVerbose(@"%@: %@", THIS_FILE, THIS_METHOD);

}

iOS XMPP怎么實(shí)現(xiàn)語(yǔ)音聊天

前提條件

另外必須了解一些CoreData相關(guān)知識(shí);

聊天設(shè)置原理

在init初始化時(shí):發(fā)送普通文本消息同樣在XMPPManager中進(jìn)行封裝;

在聊天頁(yè)面的viewDidload中:發(fā)送普通消息;

刷新消息的方法,需要熟悉CoreData知識(shí);

發(fā)送圖片等消息(重點(diǎn))

送視頻等其他文件也是一樣,xmpp中需要將圖片轉(zhuǎn)化成NSData,然后轉(zhuǎn)化成成base64的字符串進(jìn)行傳輸,然后接收到之后再反轉(zhuǎn)化成圖片。

把圖片設(shè)置為cell的imageView,所以圖片顯示了在左邊,說(shuō)明圖片消息發(fā)送是成功的,視頻等其他類(lèi)型的消息,也是同樣的原理。

其他

具體步驟流程圖


網(wǎng)站標(biāo)題:ios開(kāi)發(fā)xmpp教程的簡(jiǎn)單介紹
文章網(wǎng)址:http://weahome.cn/article/dsopjgi.html

其他資訊

在線咨詢(xún)

微信咨詢(xún)

電話咨詢(xún)

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部