Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

nsIWebSocketListener

This article needs a technical review. How you can help.

Implement this interface to receive WebSocket traffic events asynchronously after calling nsIWebSocketChannel.asyncOpen().
1.0
28
Introduced
Gecko 8.0
Inherits from: nsISupports Last changed in Gecko 8.0 (Firefox 8.0 / Thunderbird 8.0 / SeaMonkey 2.5)

Method overview

void onAcknowledge(in nsISupports aContext, in PRUint32 aSize);
void onBinaryMessageAvailable(in nsISupports aContext, in ACString aMsg);
void onMessageAvailable(in nsISupports aContext, in AUTF8String aMsg);
void onServerClose(in nsISupports aContext, in unsigned short aCode, in AUTF8String aReason);
void onStart(in nsISupports aContext);
void onStop(in nsISupports aContext, in nsresult aStatusCode);

Methods

onAcknowledge()

Called to acknowledge a message sent via nsIWebSocketChannel.sendMsg() or nsIWebSocketChannel.sendBinaryMsg().

void onAcknowledge(
  in nsISupports aContext,
  in PRUint32 aSize
);
Parameters
aContext
User defined context.
aSize
Number of bytes placed in OS send buffer.

onBinaryMessageAvailable()

Called when a binary message has been received.

void onBinaryMessageAvailable(
  in nsISupports aContext,
  in ACString aMsg
);
Parameters
aContext
User defined context.
aMsg
The message data.

onMessageAvailable()

Called when a text message has been received.

void onMessageAvailable(
  in nsISupports aContext,
  in AUTF8String aMsg
);
Parameters
aContext
User defined context.
aMsg
The message data, as a UTF-8 string.

onServerClose()

Called when the server sends a close message. In the case of errors, onStop() may be called without this method ever getting called.

No additional messages through onMessageAvailable(), onBinaryMessageAvailable()() or onAcknowledge()() will be delievered to the listener after onServerClose() is called, but outgoing messages can still be sent through the nsIWebSocketChannel connection.

void onServerClose(
  in nsISupports aContext,
  in unsigned short aCode,
  in AUTF8String aReason
);
Parameters
aContext
User defined context.
aCode
The WebSocket closing handshake status code; see Status codes for possible values.
aReason
A text string explaining the reason for the closure of the connection.

onStart()

Called to signify the establishment of the message stream. Any listener that receives onStart() will also receive OnStop().

void onStart(
  in nsISupports aContext
);
Parameters
aContext
User defined context.

onStop()

Called to signify the completion of the message stream. This is the final notification the listener will receive; once it's been received, the WebSocket connection is complete. This event can be received in error cases even if nsIWebSocketChannel.close() has not been called.

void onStop(
  in nsISupports aContext,
  in nsresult aStatusCode
);
Parameters
aContext
User defined context.
aStatusCode
Reason for stopping (NS_OK if completed successfully).

See also

Document Tags and Contributors

 Contributors to this page: Sheppy, kscarfone
 Last updated by: Sheppy,