HTML5技术

Bayeux协议 - 亮0000仔(13)

字号+ 作者:H5之家 来源:H5之家 2015-12-07 17:06 我要评论( )

[ { "channel": "/meta/subscribe", "clientId": "Un1q31d3nt1f13r", "subscription": "/foo/**" } ] 4.5.2. 订阅响应 subscribe Response A Bayeux server MUST respond to a subscribe request with a subscribe

[
{
"channel": "/meta/subscribe",
"clientId": "Un1q31d3nt1f13r",
"subscription": "/foo/**"
}
]

4.5.2. 订阅响应 subscribe Response

A Bayeux server MUST respond to a subscribe request with a subscribe response message. 

Bayeux服务端必须用订阅响应消息对订阅请求作出响应。

A Bayeux server MAY send event messages for the client in the same HTTP response as the subscribe response, including events for the channels just subscribed to. 

Bayeux服务端可以在和订阅响应同样的HTTP响应中给客户端发送事件消息,包括所订阅通道的事件。

 

A subscribe responses MUST contain the message fields: 

一个订阅响应必须包含的消息字段:

channel
value "/meta/subscribe"
值为"/meta/subscribe"
successful
boolean indicating the success or failure of the subscribe
表明订阅成功或失败的布尔值
clientId
The negotiated client ID
协商的客户端ID
subscription
a channel name or a channel pattern or an array of channel names and channel patterns. 
一个通道名称或者一个通道模式或者一个通道名称和通道模式的数组

A subscribe response MAY contain the message fields: 
一个订阅响应可能包含的消息字段:
error
advice
ext
id
same value as request message id
和请求消息id相同
timestamp 
An example successful subscribe response is: 
一个成功的订阅响应例子:
[
{
"channel": "/meta/subscribe",
"clientId": "Un1q31d3nt1f13r",
"subscription": "/foo/**",
"successful": true,
"error": ""
}
]
An example failed subscribe response is: 
一个失败的订阅响应例子:
[
{
"channel": "/meta/subscribe",
"clientId": "Un1q31d3nt1f13r",
"subscription": "/bar/baz",
"successful": false,
"error": "403:/bar/baz:Permission Denied"
}
]

4.6. 取消订阅 unsubscribe 4.6.1. 取消订阅请求 unsubscribe Request

A connected Bayeux client may send unsubscribe messages to cancel interest in a channel and to stop published message delivery from the server to the unsubscribe channel. 

一个已连接Bayeux客户端可以发送取消订阅消息,取消关心的一个通道,并停止从服务端投递到取消订阅通道的发布消息。

A unsubscribe request MUST contain the message fields:

一个取消订阅请求必须包含的消息字段:

channel 
value "/meta/unsubscribe" 
值为"/meta/unsubscribe" 
clientId 
The client ID returned in the handshake response 
握手响应中返回的客户端ID
subscription 
a channel name or a channel pattern or an array of channel names and channel patterns.
一个通道名称或者一个通道模式或者一个通道名称和通道模式的数组

A unsubscribe request MAY contain the message fields:

一个取消订阅请求可能包含的消息字段:

ext
id
An example unsubscribe request is: 
一个取消订阅请求的例子:
[
{
"channel": "/meta/unsubscribe",
"clientId": "Un1q31d3nt1f13r",
"subscription": "/foo/**"
}
]

4.6.2. 取消订阅响应 unsubscribe Response

A Bayeux server MUST respond to a unsubscribe request with a unsubscribe response message. 

Bayeux服务端必须用取消订阅响应消息对取消订阅请求做出响应。

A Bayeux server MAY send event messages for the client in the same HTTP response as the unsubscribe response, including events for the channels just unsubscribed to as long as the event was processed before the unsubscribe request. 

Bayeux服务端可以在和取消订阅响应同样的HTTP响应中给客户端发送事件消息,包括取消订阅通道的事件,只要事件在取消请求前处理。

 

A unsubscribe responses MUST contain the message fields: 
一个取消订阅响应必须包含的消息字段:
channel
value "/meta/unsubscribe"
值为"/meta/unsubscribe"
successful
boolean indicating the success or failure of the unsubscribe operation
表明取消订阅操作成功或失败的布尔值
clientId
The negotiated client ID
subscription
a channel name or a channel pattern or an array of channel names and channel patterns. 
一个通道名称或者一个通道模式或者一个通道名称和通道模式的数组

A unsubscribe response MAY contain the message fields: 
一个取消订阅响应可能包含的消息字段:
error
advice
ext
id
same value as request message id
和请求消息id相同
timestamp 
An example unsubscribe response is: 
一个取消订阅响应的例子:
[
{
"channel": "/meta/unsubscribe",
"clientId": "Un1q31d3nt1f13r",
"subscription": "/foo/**",
"successful": true,
"error": ""
}
]

5. 事件消息定义 Event Message Definitions

 

1.本站遵循行业规范,任何转载的稿件都会明确标注作者和来源;2.本站的原创文章,请转载时务必注明文章作者和来源,不尊重原创的行为我们将追究责任;3.作者投稿可能会经我们编辑修改或补充。

相关文章
  • HTTP协议学习随笔 - 糖醋酸辣椒

    HTTP协议学习随笔 - 糖醋酸辣椒

    2017-05-01 18:03

  • 计算机网络——DNS协议的学习与实现 - 学数学的程序猿

    计算机网络——DNS协议的学习与实现 - 学数学的程序猿

    2017-04-16 10:00

  • 跨平台的.NET邮件协议MailKit组件解析 - 彭泽0902

    跨平台的.NET邮件协议MailKit组件解析 - 彭泽0902

    2017-03-17 13:01

  • TCP/IP协议族(一) HTTP简介、请求方法与响应状态码 - 青玉伏案

    TCP/IP协议族(一) HTTP简介、请求方法与响应状态码 - 青玉伏案

    2017-02-03 11:02

网友点评
r