#include "domstubs.idl"

#include "nsIDOMEventTarget.idl"

interface nsIVariant;

[scriptable, builtinclass, uuid(ee669438-60ff-425c-91b8-2e29bfa6d4ae)]
interface nsIDOMDataChannel : nsIDOMEventTarget
{
  readonly attribute DOMString label;
  readonly attribute DOMString protocol;
  readonly attribute boolean reliable;
  readonly attribute boolean ordered;

  readonly attribute DOMString readyState;
  readonly attribute unsigned long bufferedAmount;

  readonly attribute unsigned short id;
  readonly attribute unsigned short stream; /* deprecated name for 'id' */

  [implicit_jscontext] attribute jsval onopen;
  [implicit_jscontext] attribute jsval onerror;
  [implicit_jscontext] attribute jsval onclose;
  [implicit_jscontext] attribute jsval onmessage;

  attribute DOMString binaryType;

  void close();

  /**
   * Transmits data to other end of the connection.
   * @param data The data to be transmitted.  Arraybuffers and Blobs are sent as
   * binary data.  Strings are sent as UTF-8 text data.  Other types are
   * converted to a String and sent as a String.
   * @return if the connection is still established and the data was queued or
   *         sent successfully.
   */
  void send(in nsIVariant data);
};
