RFC2616中8.1.4章节所建议的是一个单独的客户端不应该维护和任何服务端多于2个以上的连接,因此,Bayeux协议禁止为了在一个客户端中运行处理所有应用(基于Bayeux或其他),而有2个以上HTTP请求来被一个服务端同时处理,。
1.4.2. 非HTTP传输While HTTP is the predominant transport protocol used on the internet, it is not intended that it will be the only transport for Bayeux. Other transports that support a request/response paradigm may be used. However this document assumes HTTP for reasons of clarity. When non-HTTP connection-level transport mechanisms are employed, conforming Bayeux servers and clients MUST still conform to the semantics of the JSON messages outlined in this document.
HTTP是在因特网上使用的占据统治地位的传输协议,并非是传输Bayeux的唯一方式。其他支持请求/响应模式的传输方式也可以被使用。为了清晰起见,本文假设使用HTTP。使用非HTTP连接级别传输机制时,符合Bayeux的服务端和客户端仍必须符合文本所描述的JSON消息语义。
Several of the "transport types" described in this document are distinguished primarily by how they wrap messages for delivery over HTTP and the sequence and content of the HTTP connections initiated by clients. While this may seem like a set of implementation concerns to observant readers, the difficulties of creating interoperable implementations without specifying these semantics fully is a primary motivation for the development of this specification. Were the deployed universe of servers and clients more flexible, it may not have been necessary to develop Bayeux.
本文所描述的多种传输方式,其区分主要在于如何包装在HTTP上投递的消息,顺序和客户端发起连接的HTTP内容。虽然这可能看起来像是一系列深层次读者才关切的实现,但创建可交互实现而不完全指定语义的难度是开发此规范的一个主要动机。要是世界范围的服务器和客户端能更灵活的部署,就没有必要开发Bayeux了。
Regardless, care has been taken in the development of this specification to ensure that future clients and servers which implement differing connection-level strategies and encodings may still evolve and continue to be conforming Bayeux implementations so long as they implement the JSON-based public/subscribe semantics outlined herein.
TODO?
The rest of this document speaks as though HTTP will be used for message transport.
本文剩余部分会使用HTTP来讲述消息传输。
1.4.3. JavascriptThe majority of Bayeux clients will be implemented in JavaScript and will be running within the security framework of a client browser. For applications that need to communicate with multiple servers, the client implementation MUST adhere to the single origin policy for security.
多数Bayeux客户端会用JavaScript实现,并运行于一个客户端浏览器的安全框架内。为满足和多服务端的通信需要,基于安全考虑,客户端实现必须固守单源策略。
1.4.4. 客户端至服务端的时间传送Client to Server event deliveryA Bayeux event is sent from the client to the server via a HTTP request initiated by a user agent and transmitted to an origin server via a chain of zero or more intermediaries (proxy, gateway or tunnel):
一个Bayeux事件从客户端发送至服务端,是由一个用户代理发起的HTTP请求,经过若干环节的中介(代理,网关,或通道)被传送到原始服务器端。
BC ---------- U ---------- P ------------ O ---------- BS
| --M0(E)--> | | | |
| | ---HTTP request(M0(E))--> | |
| | | | --M0(E)--> |
| | | | <---M1---- |
| | <---HTTP response(M1)---- | |
| <---M1--- | | | |
| | | | |
The figure above represents a Bayeux event E encapsulated in a Bayeux message M0 being sent from a Bayeux client BC to a Bayeux server BS via a HTTP request transmitted from a User Agent U to to an Origin server O via a proxy P. The HTTP response contains another Bayeux message M1 that will at least contain the protocol response to M0, but may contain other Bayeux events initiated on the server or on other clients.
如上图所示,Bayeux事件E被封装成Bayeux消息M0,从Bayeux客户端BC发往Bayeux服务端BS,是通过从用户代理U经由代理P到原始服务器O的HTTP请求传输的。HTTP响应所包含的另一个Bayeux消息M1,不仅包含M0的协议响应,也可能包含服务端或其他客户端发起的其他Bayeux事件。
1.4.5. 服务端至客户端的事件传送Server to Client event deliveryA Bayeux event is sent from the server to the client via a HTTP response to a HTTP request sent in anticipation by a user agent and transmitted to an origin server via a chain of zero or more intermediaries (proxy, gateway or tunnel):
一个Bayeux事件从服务端发送至客户端, 是由一个用户代理预先发起HTTP请求的HTTP响应,经过若干环节的中介(代理,网关,或通道),被传送到原始服务器端。
BC ---------- U ---------- P ------------ O ---------- BS
| ---M0---> | | | |
| | --- HTTP request(M0) ---> | |
| | | | ----M0---> |
~ ~ ~ ~ ~ wait
| | | | <--M1(E)-- |
| | <--HTTP response(M1(E))-- | |
| <--M1(E)-- | | | |
~ ~ ~ ~ ~
The figure above represents a Bayeux message M0 being sent from a Bayeux client BC to a Bayeux server BS via a HTTP request transmitted from a User Agent U to to an Origin server O via a proxy P. The message M0 is sent in anticipation of a Bayeux event to be delivered from server to client and the Bayeux server waits for such an event before sending a response. A Bayeux event E is shown being delivered via Bayeux message M1 in the HTTP response. M1 may contain zero, one or more Bayeux events destined for the Bayeux client.