diffusion
Version:
Diffusion JavaScript client
53 lines (50 loc) • 2.62 kB
JavaScript
var CloseReason = require('../node_modules/client/close-reason');
/**
* @typedef {Object} CloseReason
* @property {Number} id - unique id
* @property {String} message - message with further details
*/
/**
* Enum representing the reason that the session has been closed.
*
* @example
* diffusion.connect({...}).then(function(session) {...}, function(err) {
* switch(err) {
* case diffusion.clients.CloseReason.CLOSED_BY_CLIENT:
* // Do something
* case diffusion.clients.CloseReason.ACCESS_DENIED:
* // Do something else
* ...
* }
* });
*
* @readonly
* @enum {CloseReason}
* @memberOf diffusion.clients
* @alias CloseReason
*/
module.exports = {
/** The session has been closed by the client. */
CLOSED_BY_CLIENT: new CloseReason(0, "The session was closed by the client", false),
/** The session has been closed by the server, or another session using the {@link session.clients} feature. */
CLOSED_BY_SERVER : new CloseReason(1, "The session was closed by the server", false),
/** Whilst disconnected, the client explicitly aborted a reconnect attempt/ */
RECONNECT_ABORTED : new CloseReason(2, "Client aborted a reconnect attempt", false),
/** The connection attempt timed out. */
CONNECTION_TIMEOUT : new CloseReason(3, "The connection attempt timed out", false),
/** The connection handshake was rejected by the server. */
HANDSHAKE_REJECTED : new CloseReason(4, "The connection handshake was rejected by the server", false),
/** There was an error parsing the handshake response - usually indicative of incompatible protocol versions. */
HANDSHAKE_ERROR : new CloseReason(5, "There was an error parsing the handshake response", false),
/** There was an unexpected error with the network connection. */
TRANSPORT_ERROR : new CloseReason(6, "There was an unexpected error with the connection", true),
/** The client could not establish a connection to the server. */
CONNECTION_ERROR : new CloseReason(7, "The client could not establish a connection to the server", true),
/** The client detected that the connection was idle. */
IDLE_CONNECTION : new CloseReason(8, "The activity monitor detected the connection was idle", true),
/** Message loss after reconnection has been detected. */
LOST_MESSAGES : new CloseReason(16, "Loss of messages has been detected", false),
/** The connection attempt failed due to a security restraint. */
ACCESS_DENIED : new CloseReason(
99, "The connection attempt was rejected by the server because authentication failed", false)
};