1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
5  * You can obtain one at http://mozilla.org/MPL/2.0/. */
6 
7 #ifndef NETWERK_SCTP_DATACHANNEL_DATACHANNELLISTENER_H_
8 #define NETWERK_SCTP_DATACHANNEL_DATACHANNELLISTENER_H_
9 
10 #include "nsISupports.h"
11 #include "nsString.h"
12 
13 namespace mozilla {
14 
15 // Implemented by consumers of a Channel to receive messages.
16 // Can't nest it in DataChannelConnection because C++ doesn't allow forward
17 // refs to embedded classes
18 class DataChannelListener {
19  public:
20   virtual ~DataChannelListener() = default;
21 
22   // Called when a DOMString message is received.
23   virtual nsresult OnMessageAvailable(nsISupports* aContext,
24                                       const nsACString& message) = 0;
25 
26   // Called when a binary message is received.
27   virtual nsresult OnBinaryMessageAvailable(nsISupports* aContext,
28                                             const nsACString& message) = 0;
29 
30   // Called when the channel is connected
31   virtual nsresult OnChannelConnected(nsISupports* aContext) = 0;
32 
33   // Called when the channel is closed
34   virtual nsresult OnChannelClosed(nsISupports* aContext) = 0;
35 
36   // Called when the BufferedAmount drops below the BufferedAmountLowThreshold
37   virtual nsresult OnBufferLow(nsISupports* aContext) = 0;
38 
39   // Called when the BufferedAmount drops to 0
40   virtual nsresult NotBuffered(nsISupports* aContext) = 0;
41 };
42 
43 }  // namespace mozilla
44 
45 #endif
46