HTML5技术

Bayeux协议 - 亮0000仔(10)

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

一个Bayeux客户端往/meta/handshake发送一个消息来开始一个连接协商。对同域连接,握手请求必须做为application/x-www-form-urlencoded编码的POST请求的message参数发送到服务端。对跨域连接,握手请求必须作为url

一个Bayeux客户端往/meta/handshake发送一个消息来开始一个连接协商。对同域连接,握手请求必须做为application/x-www-form-urlencoded编码的POST请求的message参数发送到服务端。对跨域连接,握手请求必须作为url编码的GET请求的为回调轮询设置的jsonp参数发往服务端。

 

A handshake request MUST contain the message fields:

channel 
value "/meta/handshake" 
version 
The version of the protocol supported by the client. 
supportedConnectionTypes 
An array of the connection types supported by the client for the purposes of the connection being negotiated. This list MAY be a subset of the connection types actually supported if the client wishes to negotiate a specific connection type.
一个握手请求必须包含的消息字段:
channel 
value "/meta/handshake" 
值为 /meta/handshake
version 
The version of the protocol supported by the client. 
客户端支持的协议版本
supportedConnectionTypes 
An array of the connection types supported by the client for the purposes of the connection being negotiated. This list MAY be a subset of the connection types actually supported if the client wishes to negotiate a specific connection type. 
客户端支持的一个连接类型数组,用做连接协商。如果客户端想协商为一种特定的连接类型,则支持的连接类型列表可以是实际支持连接类型的子列表。

A handshake request MAY contain the message fields:

一个握手请求可以包含的消息字段:

minimumVersion
ext
id

A client SHOULD NOT send any other message in the request with a handshake message. A server MUST ignore any other message sent in the same request as a handshake message. An example handshake request is:

[
{
"channel": "/meta/handshake",
"version": "1.0",
"minimumVersion": "1.0beta",
"supportedConnectionTypes": ["long-polling", "callback-polling", "iframe"]
}
]
客户端不应该在握手消息的请求中发送其他消息。服务端必须忽略和握手消息中同一个请求中的其他消息。
握手请求示例如下:
[
{
"channel": "/meta/handshake",
"version": "1.0",
"minimumVersion": "1.0beta",
"supportedConnectionTypes": ["long-polling", "callback-polling", "iframe"]
}
]

4.1.2. 握手响应 handshake Response

A Bayeux server MUST respond to a handshake request with a handshake response message in the body content of the response. For cross domain connections that have the 'jsonp' parameter set, the message body may be encapsulated in a jsonp callback method.

Bayeux服务端必须在响应体内容中包含握手响应消息对握手请求作出响应。对设置jsonp参数的跨域连接,消息体必须封装在json回调方法中。

 

Successful handshake response

成功的握手响应

A successful handshake responses MUST contain the message fields: 

一个成功的握手影响必须包含以下消息字段:

channel 
value "/meta/handshake"
值为 /meta/handshake
 
version
supportedConnectionTypes
The connection types supported by the server for the purposes of the connection being negotiated. This list MAY be a subset of the connection types actually supported if the server wishes to negotiate a specific connection type. This list MUST contain at list one element in common with the supportedConnectionType provided in the handshake request. If there are no connectionTypes in common, the handshake response MUST be unsuccessful.
服务端支持的连接类型,用作连接协商。如果服务端想协商为一种特定的连接类型,则连接支持列表可以是实际支持的子列表。服务端连接支持列表必须至少包含一种,和握手请求中支持连接类型中所提供的相同。如果没有共有的连接类型,握手响应就必须是不成功的。
 
clientId 
A newly generated unique clientId.
一个新产生的唯一的clientId。
 
successful 
value true
值为真

A successful handshake response MAY contain the message fields:

一个成功的握手响应可以包含的消息字段:

 

minimumVersionadvice
ext
id
same value as request message id 
和请求消息id相同

authSuccessful 
Value true, this field may be included to support prototype client implementations that required the authSuccessful field
值为真,这个字段可以包含,以支持需要authSuccessful字段的原型客户端实现。
 
An example successful handshake response is: [
{
"channel": "/meta/handshake",
"version": "1.0",
"minimumVersion": "1.0beta",
"supportedConnectionTypes": ["long-polling","callback-polling"],
"clientId": "Un1q31d3nt1f13r",
"successful": true,
"authSuccessful": true,
"advice": { "reconnect": "retry" }
}
]

Unsuccessful handshake response

不成功握手响应

An unsuccessful handshake response MUST contain the message fields: 

不成功的握手响应必须包含的消息字段:

 

 

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

网友点评
5