michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this file, michael@0: * You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "domstubs.idl" michael@0: #include "nsITCPSocketChild.idl" michael@0: michael@0: // Bug 797561 - Expose a server tcp socket API to web applications michael@0: /** michael@0: * nsIDOMTCPServerSocket michael@0: * michael@0: * An interface to a server socket that can accept incoming connections for gaia apps. michael@0: */ michael@0: [scriptable, uuid(821638a1-5327-416d-8031-668764f2ec04)] michael@0: interface nsIDOMTCPServerSocket : nsISupports michael@0: { michael@0: /** michael@0: * The port of this server socket object. michael@0: */ michael@0: readonly attribute unsigned short localPort; michael@0: michael@0: /** michael@0: * The onconnect event handler is called when a client connection is accepted. michael@0: * The data attribute of the event passed to the onconnect handler will be a TCPSocket michael@0: * instance, which is used for communication between client and server. michael@0: */ michael@0: attribute jsval onconnect; michael@0: michael@0: /** michael@0: * The onerror handler will be called when the listen of a server socket is aborted. michael@0: * The data attribute of the event passed to the onerror handler will have a michael@0: * description of the kind of error. michael@0: */ michael@0: attribute jsval onerror; michael@0: michael@0: /** michael@0: * Close the server socket. michael@0: */ michael@0: void close(); michael@0: }; michael@0: michael@0: /** michael@0: * Internal interfaces for use in cross-process server-socket implementation. michael@0: * Needed to account for multiple possible types that can be provided to michael@0: * the socket callbacks as arguments. michael@0: * michael@0: * These interfaces are for calling each method from the server socket object michael@0: * on the parent and child side for an IPC protocol implementation. michael@0: */ michael@0: michael@0: [scriptable, uuid(b64b1e68-4efa-497c-b0d8-69f067ad5ec8)] michael@0: interface nsITCPServerSocketInternal : nsISupports michael@0: { michael@0: /** michael@0: * Initialization after creating a TCP server socket object. michael@0: * michael@0: * @param windowVal michael@0: * An object to create ArrayBuffer for this window. See Bug 831107. michael@0: */ michael@0: void init(in jsval windowVal); michael@0: michael@0: /** michael@0: * Listen on a port michael@0: * michael@0: * @param localPort michael@0: * The port of the server socket. Pass -1 to indicate no preference, michael@0: * and a port will be selected automatically. michael@0: * @param options michael@0: * An object specifying one or more parameters which michael@0: * determine the details of the socket. michael@0: * michael@0: * binaryType: "arraybuffer" to use UInt8 array michael@0: * instances in the ondata callback and as the argument michael@0: * to send. Defaults to "string", to use JavaScript strings. michael@0: * @param backlog michael@0: * The maximum length the queue of pending connections may grow to. michael@0: * This parameter may be silently limited by the operating system. michael@0: * Pass -1 to use the default value. michael@0: */ michael@0: void listen(in unsigned short localPort, in jsval options, in unsigned short backlog); michael@0: michael@0: /** michael@0: * Listener for receiving an accepted socket. michael@0: */ michael@0: void callListenerAccept(in nsITCPSocketChild socketChild); michael@0: michael@0: /** michael@0: * Listener for handling an error caused in chrome process. michael@0: */ michael@0: void callListenerError(in DOMString message, in DOMString filename, michael@0: in uint32_t lineNumber, in uint32_t columnNumber); michael@0: };