It is RECOMMENDED that Bayeux server implementations use the cookie "Bayeux_HTTP_ID" to identify a HTTP client and to thus detect multiple Bayeux clients running within the same HTTP client. Once detected, the server SHOULD not wait for messages in connect and SHOULD use the advice interval mechanism to establish traditional polling.
推荐Bayeux服务端实现用cookie"Bayeux_HTTP_ID"来标识一个HTTP客户端,以此来侦测同一个HTTP客户端内的多个Bayeux客户端。一旦侦测到,服务端不应该等待连接的消息,应该使用建议间隔机制来建立传统的轮询。
8.2 客户端多框架处理 Client Multi frame handlingIt is RECOMMENDED that Bayeux client implementations use client side persistence or cookies to detect multiple intances of Bayeux clients running within the same HTTP client. Once detected, the user MAY be offered the option to disconnect all but one of the clients. It MAY be possible for client implementations to use client side persistence to share a Bayeux client instance.
推荐Bayeux客户端实现使用客户侧的存储或cookie来侦测同一个HTTP客户端内的多Bayeux客户端实例。一旦发现,用户可以选择断开所有客户端而只保留一个。客户端实现也可能用客户端侧的持久化来共享一个Bayeux客户端实例。
9. service通道的请求/响应操作 Request / Response operation with service channels
The publish/subscribe paradigm that is directly supported by the Bayeux protocol is difficult to use to efficiently implement the request/response paradigm between a client and a server. The /service/** channel space has been designated as a special channel space to allow efficient transport of application request and responses over Bayeux channels. Messages published to service channels are not distributed to other Bayeux clients so these channels can be used for private requests between a Bayeux client and a server side handlers.
A trivial example would be an echo service, that sent any message received from a client back to that client unaltered. Bayeux clients would subscribe the the /service/echo channel, but the Bayeux server would not need to record this subscription. When a client publishes a message to the /service/echo channel, it will be delivered only to server-side subscribers (in an implementation depedent fashion). The server side handler for the echo service would handle each message received by publishing a response directly to the client regardless of any subscription. As the client has subscribed to /service/echo, the response message will be routed correctly within the client to the appropriate application handler.
发布订阅模式被Bayeux协议直接支持,但在客户端和服务端之间有效的实现请求响应模式就比较困难。/service/**通道空间被指定为一个特殊的通道空间,以允许基于Bayeux通道的应用请求响应的有效传输。发布到service通道的消息不被分发到其他Bayeux客户端,因此,这些通道可用作Bayeux客户端和服务端处理间的私有请求。
举一个回显服务例子,发送的任何消息原封不动的返回到那个客户端。Bayeux客户端可以订阅/service/echo通道,但是Bayeux服务端不必记录这个订阅。当客户端发布一个到/service/echo通道的消息时,仅仅会被投送到服务端的订阅者(使用实现相关的方式)。echo服务的服务端处理会直接发布接收消息的响应到客户端,而不关心任何订阅。因为客户端已经订阅到/service/echo,响应消息会被无误的路由,在客户端中应用适当的处理。