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客户端的事件消息传送。
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"
}
]
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"
}
]