RVP:存在和即时消息传送协议 (2)

响应

作为对 pragma/notify 的 Notification-Type 的成功 SUBSCRIBE 请求的响应,PRESENCE SERVICE 返回一个响应代码:200 - Successful(成功)。响应标头包含有关成功订阅的详细信息,其中包括 Subscription-Id 标头和 Subscription-Lifetime 标头,这些标头可能与所请求的不同。

作为对 update/propchange 的 Notification-Type 的成功 SUBSCRIBE 请求的响应,PRESENCE SERVICE 返回一个响应代码:207 - Multi Status(多重状态)。响应标头包含有关成功订阅的详细信息,如上所述。还可能有一个包含所请求的属性当前值的 XML 主体。

在刷新一个租用时,来自 PRESENCE SERVICE 的成功响应会返回一个响应代码:200 - Successful。同样地,响应标头包含有关成功订阅的详细信息,其中包括 Subscription-Id 标头和 Subscription-Lifetime 标头,这些标头可能与所请求的不同。

示例

以下示例说明如何创建一个登录订阅和一个属性订阅。

登录订阅

当一个 PRESENTITY 登录时,它可以创建一个“本地节点”和一个关联 URL。例如,假定 PRINCIPAL http://im.acme.com/instmsg/aliases/maxb 在机器 198.176.154.132 上运行一个 PRESENTITY。当 PRESENTITY 登录时,它会创建一个本地节点 http://198.176.154.132:1234。假定 PRINCIPAL 由服务器 im.acme.com 托管,PRESENTITY 建立对节点 http://im.acme.com/instmsg/aliases/maxb 的登录订阅,将本地节点指定为回调。以下示例说明如何创建这样的登录订阅。

          >> 请求 
           
          SUBSCRIBE /instmsg/aliases/maxb HTTP/1.1 
          Subscription-Lifetime: 14400 
          Notification-Type: pragma/notify 
          Call-Back: http://198.176.154.132:1234 
          RVP-Notifications-Version: 0.2 
          Host: imhome1.acme.com 
          Content-Length: 0 
          RVP-From-Principal: http://im.acme.com/instmsg/aliases/maxb 
           
          >> 响应 
           
          HTTP/1.1 200 Successful 
          Subscription-Id: 98210 
          Subscription-Lifetime: 14400 
          RVP-Notifications-Version: 0.2 

属性订阅

上例中的 PRINCIPAL 对节点 http://im.example.com/instmsg/aliases/deriks 的属性进行了永久性登录订阅。Call-Back 标头是订阅者 maxb 的逻辑 URL,允许更多保护。然而,这并不意味着 maxb 需要向 im.acme.com 上他的逻辑节点发出 SUBSCRIBE 请求,以转发属性更新。以下示例说明如何创建这样的属性订阅。

          >> 请求 
           
          SUBSCRIBE http://im.example.com/instmsg/aliases/deriks HTTP/1.1 
          Subscription-Lifetime: 14400 
          Notification-Type: update/propchange 
          Call-Back: http://im.acme.com/instmsg/aliases/maxb 
          RVP-Notifications-Version: 0.2 
          Host: im.example.com 
          Content-Length: 0 
          RVP-From-Principal: http://im.acme.com/instmsg/aliases/maxb 
           
          >> 响应 
           
          HTTP/1.1 207 Multi-Status 
          Subscription-Id: 79 
          Subscription-Lifetime: 14400 
          Content-Type: text/xml 
          Content-Length: XXXX 
          RVP-Notifications-Version: 0.2 
           
          <?xml.version="1.0"?> 
          <d:multistatus xmlns:d="DAV:" 
          xmlns:r="http://schemas.microsoft.com/rvp/"> 
               <d:response> 
                    <d:href> 
 http://im.example.com/instmsg/aliases/deriks 
                    </d:href> 
                    <d:propstat> 
                            <d:prop> 
                                    <r:state><r:offline/></r:state> 
                                    <d:displayname>Derik</d:displayname> 
                                    <r:email>deriks@example.com</r:email> 
                                    <r:mobile-state>0</r:mobile-state> 
                                    <r:mobile-description> 
                                    </r:mobile-description> 
                            </d:prop> 
                            <d:status>HTTP/1.1.200.Successful</d:status> 
                    </d:propstat> 
               </d:response> 
          </d:multistatus>          
           

UNSUBSCRIBE

UNSUBSCRIBE 方法,取自 GENA,用来删除使用 SUBSCRIBE 请求建立的订阅。Subscription-Id 标头用来唯一地指定应该取消的订阅。谁可以撤消订阅是由 PRESENCE SERVICE 决定的。

示例

以下示例说明 WATCHER 如何发出一个 UNSUBSCRIBE 请求,以阻止接收来自 im.stockquotes.com 的某一股票的进一步更新。

          >> 请求 
           
          UNSUBSCRIBE /stock/companyA HTTP/1.1 
          Host: im.stockquotes.com 
          RVP-Notifications-Version: 0.2 
          RVP-From-Principal: http://im.acme.com/instmsg/aliases/maxb 
          Subscription-Id: 1234 
          Content-Length: 0 
           
          >> 响应 
           
          HTTP/1.1 200 Successful 
          RVP-Notifications-Version: 0.2 
           

SUBSCRIPTIONS

新的 RVP SUBSCRIPTIONS 方法提取服务器节点上的活动订阅列表。可能的用途包括:查看分发列表成员资格的 WATCHER,或查看监视其在线状态的 WATCHERS 列表的 RVP PRESENTITIES。

请求包含请求者感兴趣的订阅的 Notification-Type(update/propchange 或 pragma/notify)。这就是在建立每个订阅的对应 SUBSCRIBE 调用中发送的 Notification-Type。

答复包含 XML 主体中的一个订阅列表。每个 SUBSCRIPTIONS 请求都包含该订阅的 Subscription-Id 标头、订阅者的 URL (如果有的话)以及该订阅剩余的时间(以秒计)。

SUBSCRIPTIONS 请求使用以下新的 RVP XML 元素:subscriptions, subscription、subscription-id、timeout 和 rvp-principal。

示例

以下示例说明如何检索订阅列表以及每个订阅的剩余时间。

          >>请求 
           
          SUBSCRIPTIONS /lists/sales-event HTTP/1.1 
          Host: im.example.com 
          RVP-Notifications-Version: 0.2 
          Notification-Type: update/propchange 
          RVP-From-Principal: http://im.acme.com/instmsg/aliases/maxb 
           
          >>响应 
           
          HTTP/1.1 200 Successful 
          RVP-Notifications-Version: 0.2 
          Content-Type: text/xml 
          Content-Length: XXXX 
           
          <?xml version="1.0"?> 
          <Z:subscriptions xmlns:D="DAV:" 
          xmlns:Z=http://schemas.microsoft.com/rvp/ 
          xmlns:A=http://schemas.Microsoft.com/rvp/acl> 
               <Z:subscription> 
                       <Z:subscription-id> 456 </Z:subscription-id> 
                       <D:href> 
                               http://im.example.com/instmsg/aliases/maxb  
                       </D:href>        
                       <A:principal> 
                               <A:rvp-principal>  
                                       http://im.example.com/instmsg/aliase
                               s/maxb 
                               </A:rvp-principal> 
                       </A:principal> 
                       <D:timeout> 4789 </D:timeout> 
               </Z:subscription> 
               <Z:subscription> 
                       <D:href> 
                            http://im.example.com/instmsg/aliases/deriks 
                       </D:href> 
                       <Z:subscription-id> 6656 </Z:subscription-id> 
                       <A:principal> 
                               <A:rvp-principal>  
                                       http://im.example.com/instmsg/aliases/deriks  
                               <A:rvp-principal> 
                       </A:principal> 
                       <D:timeout> 8752 </D:timeout> 
               </Z:subscription> 
          </Z:subscriptions> 
                           

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值