1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/network/interfaces/nsIDOMTCPServerSocket.idl Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,92 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this file, 1.6 + * You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 + 1.8 +#include "domstubs.idl" 1.9 +#include "nsITCPSocketChild.idl" 1.10 + 1.11 +// Bug 797561 - Expose a server tcp socket API to web applications 1.12 +/** 1.13 + * nsIDOMTCPServerSocket 1.14 + * 1.15 + * An interface to a server socket that can accept incoming connections for gaia apps. 1.16 + */ 1.17 +[scriptable, uuid(821638a1-5327-416d-8031-668764f2ec04)] 1.18 +interface nsIDOMTCPServerSocket : nsISupports 1.19 +{ 1.20 + /** 1.21 + * The port of this server socket object. 1.22 + */ 1.23 + readonly attribute unsigned short localPort; 1.24 + 1.25 + /** 1.26 + * The onconnect event handler is called when a client connection is accepted. 1.27 + * The data attribute of the event passed to the onconnect handler will be a TCPSocket 1.28 + * instance, which is used for communication between client and server. 1.29 + */ 1.30 + attribute jsval onconnect; 1.31 + 1.32 + /** 1.33 + * The onerror handler will be called when the listen of a server socket is aborted. 1.34 + * The data attribute of the event passed to the onerror handler will have a 1.35 + * description of the kind of error. 1.36 + */ 1.37 + attribute jsval onerror; 1.38 + 1.39 + /** 1.40 + * Close the server socket. 1.41 + */ 1.42 + void close(); 1.43 +}; 1.44 + 1.45 +/** 1.46 + * Internal interfaces for use in cross-process server-socket implementation. 1.47 + * Needed to account for multiple possible types that can be provided to 1.48 + * the socket callbacks as arguments. 1.49 + * 1.50 + * These interfaces are for calling each method from the server socket object 1.51 + * on the parent and child side for an IPC protocol implementation. 1.52 + */ 1.53 + 1.54 +[scriptable, uuid(b64b1e68-4efa-497c-b0d8-69f067ad5ec8)] 1.55 +interface nsITCPServerSocketInternal : nsISupports 1.56 +{ 1.57 + /** 1.58 + * Initialization after creating a TCP server socket object. 1.59 + * 1.60 + * @param windowVal 1.61 + * An object to create ArrayBuffer for this window. See Bug 831107. 1.62 + */ 1.63 + void init(in jsval windowVal); 1.64 + 1.65 + /** 1.66 + * Listen on a port 1.67 + * 1.68 + * @param localPort 1.69 + * The port of the server socket. Pass -1 to indicate no preference, 1.70 + * and a port will be selected automatically. 1.71 + * @param options 1.72 + * An object specifying one or more parameters which 1.73 + * determine the details of the socket. 1.74 + * 1.75 + * binaryType: "arraybuffer" to use UInt8 array 1.76 + * instances in the ondata callback and as the argument 1.77 + * to send. Defaults to "string", to use JavaScript strings. 1.78 + * @param backlog 1.79 + * The maximum length the queue of pending connections may grow to. 1.80 + * This parameter may be silently limited by the operating system. 1.81 + * Pass -1 to use the default value. 1.82 + */ 1.83 + void listen(in unsigned short localPort, in jsval options, in unsigned short backlog); 1.84 + 1.85 + /** 1.86 + * Listener for receiving an accepted socket. 1.87 + */ 1.88 + void callListenerAccept(in nsITCPSocketChild socketChild); 1.89 + 1.90 + /** 1.91 + * Listener for handling an error caused in chrome process. 1.92 + */ 1.93 + void callListenerError(in DOMString message, in DOMString filename, 1.94 + in uint32_t lineNumber, in uint32_t columnNumber); 1.95 +};