Skip navigation.

Meta Events

The dojox.cometd client publishes events to the local dojo topic to notifiy applications of the connected state of the client. Typically the topic is "/cometd/meta", but can be "/someprefix/meta" if multiple cometd connections are used by a client. Note that this is a dojo topic and NOT a cometd channel, thus it is only available within the client. The following code snippet demonstrates how to subscribe to the "/comet/meta" topic:

var handle = dojo.subscribe("/cometd/meta", this, function(event){
  switch(event.action){
    // handle actions
  }
});

The events published javascript objects with the general format of:

{
  cometd:this /*reference to cometd object - generally same as dojox.cometd*/,
  action:"action" /*name of action*/,
  successful:true /* or false */,
  state:this.state() /*"DISCONNECTED"|"CONNECTING"|"CONNECTED"|"DISCONNECTING" */
}

Handshake Event

Handshake events are published with action:"handshake" as the result of every handshake success, failure or timeout.

A handshake is initiated whenever cometd.init() is called and whenever advice is received from the server to re-handshake (typically after a transient network failured caused the server to timeout the client or after a server restart). Handshake events contain the additional boolean field "reestablish" which if true indicates that a the handshake was the result of an automatic re-handshake.

Cometd subscriptions and application server-side state are not maintained over handshake events and
typical handling of a re-establish handshake will be to resubscribe to cometd channels and to send messages to re-establish server side application state.

Connect Event

Connect events are published with action: "connect" whenever a cometd /meta/connect message completes with success, failure or timeout. An unsuccessful connect does not mean that the commetd connection state is lost and typically the cometd client will retry the connect according to the current advice settings.

Disconnect Event

Disconnect events are published with action: "disconnect" whenever a cometd /meta/disconnect message completes with success, failure or timeout. An successful disconnect will destroy all serverside connection state including subscriptions. An unsuccessful disconnect means that the server state is unknown.