认识smack3.0.4基本对象 - Presence

一 Presence对象介绍

与IQ一样,Presence也是继承自XMPP的基类Packet信息包,Presence主要有两个用途:1)告诉服务器所有客户端当前所处的状态,2)发出添加/删除好友请求;每个Presence信息包都有一个类型属性Presence.Type,如下:

  • available: 表示处于在线状态
  • unavailable: 表示处于离线状态
  • subscribe: 表示发出添加好友的申请
  • unsubscribe: 表示发出删除好友的申请
  • unsubscribed: 表示拒绝添加对方为好友
  • error: 表示presence信息报中包含了一个错误消息。

除了类型信息外,Presence还包含其他一些可选的属性:

  • Status: 用于表示用户状态的自定义文本,例如:外出吃饭
  • Priority: 一个表示发送者资源优先级的非负数(我尚未搞明白什么是发送者资源)
  • Mode: 表示五种状态之一:在线(默认)、聊天、离开、xa (extended away)、请勿打扰

Represents XMPP presence packets. Every presence packet has a type, which is one of the following values:

  • available -- (Default) indicates the user is available to receive messages.
  • unavailable -- the user is unavailable to receive messages.
  • subscribe -- request subscription to recipient's presence.
  • subscribed -- grant subscription to sender's presence.
  • unsubscribe -- request removal of subscription to sender's presence.
  • unsubscribed -- grant removal of subscription to sender's presence.
  • error -- the presence packet contains an error message.

A number of attributes are optional:

  • Status -- free-form text describing a user's presence (i.e., gone to lunch).
  • Priority -- non-negative numerical priority of a sender's resource. The highest resource priority is the default recipient of packets not addressed to a particular resource.
  • Mode -- one of five presence modes: available (the default), chatawayxa (extended away), and dnd (do not disturb).

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值