HTML5技术

Bayeux协议 - 亮0000仔(8)

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

"advice": { "reconnect": "retry", "interval": 1000, "callback-polling" : { "reconnect": "handshake" } } 除非是章节5和6指定的,其他任何Bayeux响应消息都可以包含一个advice字段。收到的advice总是替代之前

"advice": { 
"reconnect": "retry",
"interval": 1000,
"callback-polling" : {
"reconnect": "handshake"
}
}
除非是章节5和6指定的,其他任何Bayeux响应消息都可以包含一个advice字段。收到的advice总是替代之前接受的任何advice。
advice字段示例如下:
"advice": { 
     "reconnect": "retry",
     "interval": 1000,
     "callback-polling" : {
         "reconnect": "handshake"
     }
}

3.6.1. 重连advice reconnect advice

The reconnect advice field is a string that indicates how the client should act in the case of a failure to connect. Defined reconnect values are: 

重连advice字段是一个字符串,表明了客户端在连接失败的情况下应该如何操作。重连值定义有:

 

retry 
a client MAY attempt to reconnect with a /meta/connect after the interval (as defined by "interval" advice or client-default backoff), and with the same credentials.
重试
客户端可以在一定间隔(按照interval advice定义或客户端默认延时)后用同样的证书重连到/meta/connect。

handshake 
the server has terminated any prior connection status and the client MUST reconnect with a /meta/handshake. A client MUST NOT automatically retry if handshake advice has been received. 
握手
服务端已经终止所有之前的连接状态,客户端必须重连到/meta/handshake。如果客户端已经收到握手advice则禁止自动重试。

none 
hard failure for the connect attempt. Do not attempt to reconnect at all. A client MUST respect reconnect advice of none and MUST NOT automatically retry or handshake. Any client that does not implement all defined values of reconnect MUST NOT automatically retry or handshake.

连接完全失败。不要再试图连接。客户端必须重视none重连advice,并禁止自动重试或握手。不实现全部reconnect定义值的客户端禁止自动重连或握手。

3.6.2. 间隔advice interval advice

An integer representing the minimum period in milliseconds for a client to delay subsequent requests to the /meta/connect channel. A negative period indicates that the message should not be retried.

A client MUST implement interval support, but a client MAY exceed the interval provided by the server. A client SHOULD implement a backoff strategy to increase the interval if requests to the server fail without new advice being received from the server. 

一个提供给客户端的以秒为单位的整数所表示的最小周期,推迟后续到/meta/connect通道的请求。

客户端必须实现间隔支持,但是一个客户端可以超过服务端提供的间隔。如果到服务端请求失败而没有收到新的advice,则客户端必须实现一种退避策略以增加间隔。

3.6.3. 多客户端advice multiple-clients advice

This is a boolean field, which if true indicates that the server has detected multiple Bayeux client instances running within the same HTTP client. 

多客户端advice是一个布尔值字段,如果为真则表示服务端已经侦测到多个Bayeux客户端实例运行在同一个http客户端中。

3.6.4. 主机advice hosts advice

This is an array of strings field, which if present indicates a list of host names or IP addresses that MAY be used as alternate servers with which the client may connect. If a client receives advice to re-handshake and the current server is not included in a supplied hosts list, then the client SHOULD try the hosts in order until a successful connection is establish. Advice received during handshakes with hosts in the list supercedes any previously received advice. 

主机advice是一个数组字符串字段,所表示的是一个主机名或IP地址列表,可作为候选服务器与客户端连接。如果一个客户端接收到重新握手的advice,而当前服务器不包含在提供的主机列表中,客户端就应该按顺序尝试这些主机,知道成功建立一个连接。和列表中的主机握手过程中收到的advice,要替代之前收到的任何advice。

3.7. 连接类型 connectionType

The connectionType message field specifies the type of transport the client requires for communication. The connectionType message field MUST be included in request messages to the "/meta/connect" channel. Connection types are defined in section 4.7.

连接类型消息字段指定了客户端用来通信所需的传输类型。连接类型消息字段必须包含在到/meta/connect通道的请求消息中。连接类型定影在章节4.7。

3.8. id

An id field MAY be included in any Bayeux message with an alpha numeric value:

id = alphanum *( alphanum )

Generation of IDs is implementation specific and may be provided by the application. Messages published to /meta/** and /service/** SHOULD have id fields that are unique within the the connection.

Messages sent in response to messages delivered to /meta/** channels MUST use the same message id as the request message.

Messages sent in response to messages delivered to /service/** channels SHOULD use the same message id as the request message or an id derived from the request message id. 

一个字符数字值的id字段可以包含在任何Bayeux消息中:

id = alphanum *( alphanum )

ID的生成是实现相关的,也可有应用提供。发布到/meta/*和/service/*的消息,应该好汉id字段,并在连接内唯一。

发送到 /meta/** 通道的消息的响应消息,必须使用和请求消息同样的消息id。

发送到 /service/**通道的消息的响应消息,应该使用和请求消息同样的消息id,或者派生自请求消息id。

3.9. 时间戳 timestamp

The timestamp message field SHOULD be specified in the following ISO 8601 profile: All times SHOULD be sent in GMT time.

 

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

网友点评