HTML5技术

Bayeux协议 - 亮0000仔(14)

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

Application events are published in event messages sent from a Bayeux client to a Bayeux server and are delivered in event messages sent from a Bayeux server to a Bayeux client. 应用事件通过Bayeux客

Application events are published in event messages sent from a Bayeux client to a Bayeux server and are delivered in event messages sent from a Bayeux server to a Bayeux client.
应用事件通过Bayeux客户端发送到Bayeux服务端的事件消息发布,并通过Bayeux服务端发送到Bayeux客户端的事件消息传送。

5.1. 发布事件消息 Publish event messages 5.1.1. 发布请求 publish Request

A Bayeux client can publish events on a channel by sending event messages. An event message MAY be sent in new HTTP request or it MAY be sent in the same HTTP request as any message other than a handshake meta message. 

Bayeux客户端能在通道上发送事件消息发布事件。一个事件消息可以在新的HTTP请求中发送,或者可以和除了握手元消息之外的任何消息相同的HTTP请求中发送。

A publish message may be sent from an unconnected client (that has not performed handshaking and thus does not have a client ID). It is OPTIONAL for a server to accept unconnected publish requests and they should apply server specific authentication and authorization before doing so. 

一个发布消息可以从一个未连接的客户端发送(还没有握手因此没有客户端ID)。服务端接受未连接的发布请求是可选的,因此他们应该在这么做之前应用服务端特定的认证和授权。

 

A publish event message MUST contain the message fields: 
一个发布事件消息必须包含的消息字段:
channel
data
The message as an arbitrary JSON object 
消息可以是任何的JSON对象

A publish event message MAY contain the message fields: 
一个发布事件消息可能包含的消息字段:
clientId
The negotiated client ID
协商的客户端ID
id
A unique ID for the message generated by the client
客户端生成的唯一消息ID
ext

An example event message is: 
一个事件消息的例子:
[
{
"channel": "/some/channel",
"clientId": "Un1q31d3nt1f13r",
"data": "some application string or JSON object",
"id": "some unique message id"
}
]

5.1.2. 发布响应 publish Response

A Bayeux server MAY respond to a publish event message with a publish event acknowlegement. 

服务端可以用发布事件确认对发布事件消息做出响应。

 

A publish event message MUST contain the message fields: 
一个发布事件消息必须包含的消息字段:
channel
successful
boolean indicating the success or otherwise of the publish 
表明发布成功或其它的布尔值

A publish event response MAY contain the message fields: 
一个发布事件响应可能包含的消息字段:
id
error
ext 
An example event reponse message is: 
一个事件响应消息的例子:
[
{
"channel": "/some/channel",
"successful": true,
"id": "some unique message id"
}
]

 

5.2. 传送事件消息 Deliver Event messages

Event messages are delivered to clients if the client is subscribed to the channel of the event message. Event messages may be sent to the client in the same HTTP response as any other message other than a meta handshake response. If a Bayeux server has multiple HTTP requests from the same client, the server SHOULD deliver all available messages in the HTTP response that will be sent immediately in preference to waking a waiting connect meta message handler. Event message delivery is not acknowledged by the client. 

如果客户端订阅到事件消息的通道,事件消息就可以被传送到客户端。事件消息可以在除了元握手响应之外的任何消息相同的HTTP响应中被发往客户端。如果Bayeux服务端有来自同一客户端的多个HTTP请求,服务端应该在HTTP响应中传送所有可用消息,TODO

事件消息传送不必被客户端确认。

 

A deliver event message MUST contain the message fields: 

一个传送事件消息必须包含的消息字段:

channel
data
The message as an arbitrary JSON object 
消息可以是任何的JSON对象

A deliver event response MAY contain the message fields: 
一个传送事件响应可能包含的消息字段:
id
Unique message ID from the publisher
来自发布者的唯一消息ID
clientId
The client ID of the publisher
发布者的客户端ID
ext
advice 

An example event deliver message is: 
一个事件传送消息的例子:
[
{
"channel": "/some/channel",
"data": "some application string or JSON object",
"id": "some unique message id"
}
]

6. 传输 Transports 6.1. 长轮询 long-polling

 

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

网友点评