1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/netwerk/protocol/websocket/nsIWebSocketListener.idl Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,90 @@ 1.4 +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 1.5 +/* vim: set sw=4 ts=4 et tw=80 : */ 1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.9 + 1.10 +#include "nsISupports.idl" 1.11 + 1.12 +/** 1.13 + * nsIWebSocketListener: passed to nsIWebSocketChannel::AsyncOpen. Receives 1.14 + * websocket traffic events as they arrive. 1.15 + */ 1.16 +[scriptable, uuid(d74c96b2-65b3-4e39-9e39-c577de5d7a73)] 1.17 +interface nsIWebSocketListener : nsISupports 1.18 +{ 1.19 + /** 1.20 + * Called to signify the establishment of the message stream. 1.21 + * 1.22 + * Unlike most other networking channels (which use nsIRequestObserver 1.23 + * instead of this class), we do not guarantee that OnStart is always 1.24 + * called: OnStop is called without calling this function if errors occur 1.25 + * during connection setup. If the websocket connection is successful, 1.26 + * OnStart will be called before any other calls to this API. 1.27 + * 1.28 + * @param aContext user defined context 1.29 + */ 1.30 + void onStart(in nsISupports aContext); 1.31 + 1.32 + /** 1.33 + * Called to signify the completion of the message stream. 1.34 + * OnStop is the final notification the listener will receive and it 1.35 + * completes the WebSocket connection: after it returns the 1.36 + * nsIWebSocketChannel will release its reference to the listener. 1.37 + * 1.38 + * Note: this event can be received in error cases even if 1.39 + * nsIWebSocketChannel::Close() has not been called. 1.40 + * 1.41 + * @param aContext user defined context 1.42 + * @param aStatusCode reason for stopping (NS_OK if completed successfully) 1.43 + */ 1.44 + void onStop(in nsISupports aContext, 1.45 + in nsresult aStatusCode); 1.46 + 1.47 + /** 1.48 + * Called to deliver text message. 1.49 + * 1.50 + * @param aContext user defined context 1.51 + * @param aMsg the message data 1.52 + */ 1.53 + void onMessageAvailable(in nsISupports aContext, 1.54 + in AUTF8String aMsg); 1.55 + 1.56 + /** 1.57 + * Called to deliver binary message. 1.58 + * 1.59 + * @param aContext user defined context 1.60 + * @param aMsg the message data 1.61 + */ 1.62 + void onBinaryMessageAvailable(in nsISupports aContext, 1.63 + in ACString aMsg); 1.64 + 1.65 + /** 1.66 + * Called to acknowledge message sent via sendMsg() or sendBinaryMsg. 1.67 + * 1.68 + * @param aContext user defined context 1.69 + * @param aSize number of bytes placed in OS send buffer 1.70 + */ 1.71 + void onAcknowledge(in nsISupports aContext, in uint32_t aSize); 1.72 + 1.73 + /** 1.74 + * Called to inform receipt of WebSocket Close message from server. 1.75 + * In the case of errors onStop() can be called without ever 1.76 + * receiving server close. 1.77 + * 1.78 + * No additional messages through onMessageAvailable(), 1.79 + * onBinaryMessageAvailable() or onAcknowledge() will be delievered 1.80 + * to the listener after onServerClose(), though outgoing messages can still 1.81 + * be sent through the nsIWebSocketChannel connection. 1.82 + * 1.83 + * @param aContext user defined context 1.84 + * @param aCode the websocket closing handshake close code. 1.85 + * @param aReason the websocket closing handshake close reason 1.86 + 1.87 + */ 1.88 + void onServerClose(in nsISupports aContext, in unsigned short aCode, 1.89 + in AUTF8String aReason); 1.90 + 1.91 +}; 1.92 + 1.93 +