/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
 * You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "nsISupports.idl"

interface nsIDOMBlob;
interface nsIInputStream;
interface nsINetAddr;

%{C++
#define PRESENTATION_TCP_SESSION_TRANSPORT_CONTRACTID \
  "@mozilla.org/presentation/presentationtcpsessiontransport;1"
%}

/*
 * The callback for session transport events.
 */
[scriptable, uuid(9f158786-41a6-4a10-b29b-9497f25d4b67)]
interface nsIPresentationSessionTransportCallback : nsISupports
{
  void notifyTransportReady();
  void notifyTransportClosed(in nsresult reason);
  void notifyData(in ACString data, in boolean isBinary);
};

/*
 * App-to-App transport channel for the presentation session.
 */
[scriptable, uuid(670b7e1b-65be-42b6-a596-be571907fa18)]
interface nsIPresentationSessionTransport : nsISupports
{
  // Should be set once the underlying session transport is built
  attribute nsIPresentationSessionTransportCallback callback;

  // valid for TCP session transport
  readonly attribute nsINetAddr selfAddress;

  /*
   * Enable the notification for incoming data. |notifyData| of
   * |nsIPresentationSessionTransportCallback| can start getting invoked.
   * Should set callback before |enableDataNotification| is called.
   */
  void enableDataNotification();

  /*
   * Send message to the remote endpoint.
   * @param data The message to send.
   */
  void send(in DOMString data);

  /*
   * Send the binary message to the remote endpoint.
   * @param data: the message being sent out.
   */
  void sendBinaryMsg(in ACString data);

  /*
   * Send the blob to the remote endpoint.
   * @param blob: The input blob to be sent.
   */
  void sendBlob(in nsIDOMBlob blob);

  /*
   * Close this session transport.
   * @param reason The reason for closing this session transport.
   */
  void close(in nsresult reason);
};