channel
value "/meta/connect"
ֵΪ/meta/connect
successful
boolean indicating the success or failure of the connection
ָʾÁ¬½Óʧ°Ü»ò³É¹¦µÄ²¼¶ûÖµ
clientId
The negotiated client ID
ÐÉ̵Ŀͻ§¶ËID
A connect response MAY contain the message fields:
Ò»¸öÁ¬½ÓÏìÓ¦¿ÉÄܰüº¬µÄÏûÏ¢×ֶΣº
error
advice
ext
id
same value as request message id
ºÍÇëÇóÏûÏ¢idÏàͬ
timestamp
An example connect response is:
Á¬½ÓÏìÓ¦µÄÒ»¸öÀý×Ó£º
[
{
"channel": "/meta/connect",
"successful": true,
"error": "",
"clientId": "Un1q31d3nt1f13r",
"timestamp": "12:00:00 1970",
"advice": { "reconnect": "retry" }
}
]
The client MUST maintain only a single outstanding connect message. If the server does not have a current outstanding connect and a connect is not received within a configured timeout, then the server SHOULD act as if a disconnect message has been received.
¿Í»§¶Ë±ØÐëά»¤Î¨Ò»µÄδ¾öÁ¬½ÓÏûÏ¢¡£Èç¹û·þÎñ¶ËûÓÐÒ»¸öµ±Ç°Î´¾öµÄÁ¬½Ó£¬²¢ÇÒÔÚÅäÖõij¬Ê±Ê±¼äÄÚ£¬Ã»ÓÐÊÕµ½Ò»¸öÁ¬½Ó£¬·þÎñ¶ËÓ¦¸ÃÈÏΪÊÕµ½ÁËÒ»¸ö¶Ï¿ªÏûÏ¢¡£
4.4. ¶Ï¿ª disconnect 4.4.1. ¶Ï¿ªÇëÇó disconnect RequestWhen a connected client wishes to cease operation it should send a request to the "/meta/disconnect" channel for the server to remove any client-related state. The server SHOULD release any waiting meta message handlers. Bayeux client applications should send a disconnect request when the user shuts down a browser window or leaves the current page. A Bayeux server SHOULD not rely solely on the client sending a disconnect message to remove client-related state information because a disconnect message might not be sent from the client or the disconnect request might not reach the server.
Ò»¸öÒÑÁ¬½Ó¿Í»§¶ËÏëÖÕÖ¹²Ù×÷µÄʱºò£¬ËüÓ¦¸Ã¸ø/meta/disconnectͨµÀ·¢ËÍÒ»¸öÇëÇó£¬È÷þÎñ¶ËÒÆ³ýÈκοͻ§¶ËÏà¹ØµÄ״̬¡£·þÎñ¶ËÓ¦¸ÃÊÍ·ÅÈκεȴýÖеÄÔªÏûÏ¢´¦Àí¡£µ±Óû§¹Ø±Õä¯ÀÀÆ÷´°¿Ú»òÕßÀ뿪µ±Ç°Ò³ÃæÊ±£¬Bayeux¿Í»§¶ËÓ¦ÓÃÓ¦¸Ã·¢ËÍÒ»¸ö¶Ï¿ªÇëÇó¡£Bayeux·þÎñ¶Ë²»Ó¦¸ÃÖ»ÒÀÀµÓÚ¿Í»§¶Ë·¢ËͶϿªÏûÏ¢²ÅÒÆ³ý¿Í»§¶ËÏà¹ØµÄ״̬ÐÅÏ¢£¬ÒòΪ¶Ï¿ªÏûÏ¢¿ÉÄܲ»´Ó¿Í»§¶Ë·¢ËÍ»òÕß¶Ï¿ªÇëÇ󲻻ᵽ´ï·þÎñ¶Ë¡£
A disconnect request MUST contain the message fields:
Ò»¸ö¶Ï¿ªÇëÇó±ØÐë°üº¬µÄÏûÏ¢×ֶΣº
channel
value "/meta/disconnect"
ֵΪ/meta/disconnect
clientId
The client ID returned in the handshake response
ÎÕÊÖÏìÓ¦Öзµ»ØµÄ¿Í»§¶ËID
A disconnect request MAY contain the message fields:
Ò»¸ö¶Ï¿ªÇëÇó¿ÉÄܰüº¬µÄÏûÏ¢×ֶΣº
ext
id
An example disconnect request is:
¶Ï¿ªÇëÇóµÄÒ»¸öÀý×Ó£º
[
{
"channel": "/meta/disconnect",
"clientId": "Un1q31d3nt1f13r"
}
]
A Bayeux server MUST respond to a disconnect request with a disconnect response.
Bayeux·þÎñ¶Ë±ØÐëÓÃÒ»¸ö¶Ï¿ªÏìÓ¦¶ÔÒ»¸ö¶Ï¿ªÇëÇó×÷³öÏìÓ¦¡£
A disconnect response MUST contain the message fields:
Ò»¸ö¶Ï¿ªÏìÓ¦±ØÐë°üº¬µÄÏûÏ¢×ֶΣº
channel
value "/meta/disconnect"
ֵΪ/meta/disconnect
clientId
The client ID returned in the handshake response
ÎÕÊÖÏìÓ¦Öзµ»ØµÄ¿Í»§¶ËID
successful
boolean value indicated the success or failure of the disconnect request
±íÃ÷¶Ï¿ªÇëÇó³É¹¦»òʧ°ÜµÄ²¼¶ûÖµ
A disconnect response MAY contain the message fields:
Ò»¸ö¶Ï¿ªÏìÓ¦¿ÉÄܰüº¬µÄÏûÏ¢×ֶΣº
error
ext
id
same value as request message id
ºÍÇëÇóÏûÏ¢idÏàͬ
An example disconnect response is:
Ò»¸ö¶Ï¿ªÏìÓ¦µÄÀý×Ó£º
[
{
"channel": "/meta/disconnect",
"clientId": "Un1q31d3nt1f13r",
"successful": true
}
]
A connected Bayeux client may send subscribe messages to register interest in a channel and to request that messages published to the subscribe channel are delivered to the client.
Ò»¸öÒÑÁ¬½ÓBayeux¿Í»§¶Ë¿ÉÒÔ·¢ËͶ©ÔÄÏûÏ¢£¬µÇ¼Ç¹ØÐĵÄÒ»¸öͨµÀ£¬²¢ÇëÇó·¢²¼µ½Õâ¸ö¶©ÔÄͨµÀµÄÏûÏ¢±»·¢Ë͵½Õâ¸ö¿Í»§¶Ë¡£
A subscribe request MUST contain the message fields:
Ò»¸ö¶©ÔÄÇëÇó±ØÐë°üº¬µÄÏûÏ¢×ֶΣº
channel
value "/meta/subscribe"
ֵΪ“/meta/subscribe”
clientId
The client ID returned in the handshake response
ÎÕÊÖÏìÓ¦Öзµ»ØµÄ¿Í»§¶ËID
subscription
a channel name or a channel pattern or an array of channel names and channel patterns.
Ò»¸öͨµÀÃû³Æ»òÕßÒ»¸öͨµÀģʽ»òÕßÒ»¸öͨµÀÃû³ÆºÍͨµÀģʽµÄÊý×é
A subscribe request MAY contain the message fields:
Ò»¸ö¶©ÔÄÇëÇó¿ÉÄܰüº¬µÄÏûÏ¢×ֶΣº
ext
id
An example subscribe request is:
Ò»¸ö¶©ÔÄÇëÇóµÄÀý×Ó£º
¡¡