nsIUDPSocketChild.idl 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /* This Source Code Form is subject to the terms of the Mozilla Public
  2. * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  3. * You can obtain one at http://mozilla.org/MPL/2.0/. */
  4. #include "nsISupports.idl"
  5. #include "nsINetAddr.idl"
  6. interface nsIUDPSocketInternal;
  7. interface nsIInputStream;
  8. interface nsIPrincipal;
  9. %{ C++
  10. namespace mozilla {
  11. namespace net {
  12. union NetAddr;
  13. }
  14. }
  15. %}
  16. native NetAddr(mozilla::net::NetAddr);
  17. [ptr] native NetAddrPtr(mozilla::net::NetAddr);
  18. [scriptable, uuid(1e6ad73b-6c05-4d78-9a88-2d357b88f58b)]
  19. interface nsIUDPSocketChild : nsISupports
  20. {
  21. readonly attribute unsigned short localPort;
  22. readonly attribute AUTF8String localAddress;
  23. attribute AUTF8String filterName;
  24. // Allow hosting this over PBackground instead of PNecko
  25. [noscript] void setBackgroundSpinsEvents();
  26. // Tell the chrome process to bind the UDP socket to a given local host and port
  27. void bind(in nsIUDPSocketInternal socket, in nsIPrincipal principal,
  28. in AUTF8String host, in unsigned short port,
  29. in bool addressReuse, in bool loopback, in uint32_t recvBufferSize,
  30. in uint32_t sendBufferSize);
  31. // Tell the chrome process to connect the UDP socket to a given remote host and port
  32. void connect(in nsIUDPSocketInternal socket, in AUTF8String host, in unsigned short port);
  33. // Tell the chrome process to perform equivalent operations to all following methods
  34. void send(in AUTF8String host, in unsigned short port,
  35. [const, array, size_is(byteLength)] in uint8_t bytes,
  36. in unsigned long byteLength);
  37. // Send without DNS query
  38. void sendWithAddr(in nsINetAddr addr,
  39. [const, array, size_is(byteLength)] in uint8_t bytes,
  40. in unsigned long byteLength);
  41. [noscript] void sendWithAddress([const] in NetAddrPtr addr,
  42. [const, array, size_is(byteLength)] in uint8_t bytes,
  43. in unsigned long byteLength);
  44. // Send input stream. This must be a buffered stream implementation.
  45. void sendBinaryStream(in AUTF8String host, in unsigned short port, in nsIInputStream stream);
  46. void close();
  47. void joinMulticast(in AUTF8String multicastAddress, in AUTF8String iface);
  48. void leaveMulticast(in AUTF8String multicastAddress, in AUTF8String iface);
  49. };
  50. /*
  51. * Internal interface for callback from chrome process
  52. */
  53. [scriptable, uuid(613dd3ad-598b-4da9-ad63-bbda50c20098)]
  54. interface nsIUDPSocketInternal : nsISupports
  55. {
  56. // callback while socket is opened. localPort and localAddress is ready until this time.
  57. void callListenerOpened();
  58. // callback while socket is connected.
  59. void callListenerConnected();
  60. // callback while socket is closed.
  61. void callListenerClosed();
  62. // callback while incoming packet is received.
  63. void callListenerReceivedData(in AUTF8String host, in unsigned short port,
  64. [const, array, size_is(dataLength)] in uint8_t data,
  65. in unsigned long dataLength);
  66. // callback while any error happened.
  67. void callListenerError(in AUTF8String message, in AUTF8String filename, in uint32_t lineNumber);
  68. };