`
Blackbaby
  • 浏览: 179838 次
  • 性别: Icon_minigender_1
  • 来自: 成都
社区版块
存档分类
最新评论

smack presence问题

阅读更多

Roser#getPresence(String user) will return null if the contact has no presence information available. This could be because the contact is offline or you are not subscribed to their presence

 

If you are getting null when your contact is online then it will be (most likely) one of two things.

 

1: Either you are not subscribed to the other contacts Presence. In which case you will need to before you are allowed to track their Online/Offline status.

 

2: As AWenckus mentioned, it can sometimes take a moment for the information to be sent so if you are performing this operation as soon as you login the method may well return null.

 

Far better to add a RosterListener to your connection to listen out for Presence changes.

 

Presence presence = (Presence)packet;
Presence.Mode presenceMode = presence.getMode();

if(presenceMode == Presence.Mode.AVAILABLE) {
    // user is online and available
}

if(presenceMode == Presence.Mode.AWAY) {
    //user is away
}
take for example two users:User A,User B

User A wants to see when User B is online.

User A sends a SUBSCRIBE packet to User B

User B then decides whether or not to allow User A to see when they are online.

If they accept the subscription requests they send a SUBSCRIBED packet

If they reject the subscription request they send a UNSUBSCRIBED packet.

 

参考:http://www.igniterealtime.org/community/message/115077#115077

分享到:
评论
2 楼 Blackbaby 2012-05-21  
qmzpanda 写道
hi,有个问题我想咨询你一下:
Roster在添加RosterListener 监听后,页面通过Xbosh协议发Presence,Rosterlistener的 presenceChange()方法会有延迟,有碰到过类似问题吗?


你是做web应用吧?我们之前用的strophe.js开发  没有遇到过哦
1 楼 qmzpanda 2012-05-19  
hi,有个问题我想咨询你一下:
Roster在添加RosterListener 监听后,页面通过Xbosh协议发Presence,Rosterlistener的 presenceChange()方法会有延迟,有碰到过类似问题吗?

相关推荐

    Smack中文文档,chm格式

    Smack中文文档Smack中文文档Smack中文文档Smack中文文档Smack中文文档Smack中文文档Smack中文文档Smack中文文档Smack中文文档Smack中文文档

    smack 源码

    smack源码

    Smack中文API文档

    Smack中文API文档

    smack4.3.1

    smack用于android移动端的开发,可以结合openfire使用,进行im通信

    Smack API手册与文档

    1)smack api,基于smack官方javadoc制作而成,格式chm,语言english; 2)smack documentation,内容包括Overview,Getting Started Guide等等,格式chm,语言为中文(感谢fhqdddddd的奉献,本文档基于...

    Smack API中文版

    这个是Smack API的中文版,详细介绍了smack原理,并且有几个小例子在里面

    Android代码-Smack

    it can be embedded into your applications to create anything from a full XMPP instant messaging client to simple XMPP integrations such as sending notification messages and presence-enabling devices....

    smack4.10含源码

    Smack是一个开源,易于使用的XMPP(jabber)客户端类库。 附件是目前最新版本的smack库,含源码。

    smack api帮助文档

    smack api帮助文档官方提供的帮助工具

    Smack帮助文档中文版

    Smack帮助文档中文版:XMPP协议包括一个基本协议和许多可选扩充,像具有代表性的"JEP's".Smack 为核心XMPP协议提供了org.jivesoftware.smack包,为许多协议扩充提供了org.jivesoftware.smackx包.

    smack 3.2.2

    smack xmpp 3.2.2 for linux

    smack4.1.4 android 测试通过

    最新的 smack4.1.4 android开发demo 可以登录 已验证

    smack源码下载(java版)

    smack源码下载,java版下载,smack源码下载

    smack3.3.1源代码

    smack3.3.1源码 open fire开源的聊天服务器。客户端的核心xmpp协议的操作。

    openfire+spark+smack

    Openfire+spark+smack xmpp

    smack学习笔记

    smack xmpp 即时通讯,使用smack库结合openfire实现即时通讯

    smack包.zip

    基于openfire服务器利用Xmpp协议在Android上实现即时通讯 内含:smack.jar, smackx.jar, smackx-debug.jar, smackx-jingle.jar

    smack_3_3_0

    Android 链接openfire的smack库

    SMACK文件传输

    SMACK文件传输的介绍及代码,官网源文件

    smack4.2.2jar包

    Android端smack4.2.2 IM开发全部jar包包含jxmpp和smack。

Global site tag (gtag.js) - Google Analytics