WebSocket.hx 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /*
  2. * Copyright (C)2005-2013 Haxe Foundation
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a
  5. * copy of this software and associated documentation files (the "Software"),
  6. * to deal in the Software without restriction, including without limitation
  7. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8. * and/or sell copies of the Software, and to permit persons to whom the
  9. * Software is furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  20. * DEALINGS IN THE SOFTWARE.
  21. */
  22. // This file is generated, do not edit!
  23. package js.html;
  24. /** <div><p><strong>This is an experimental feature</strong><br>Because this feature is still in development in some browsers, check the <a href="#AutoCompatibilityTable">compatibility table</a> for the proper prefixes to use in various browsers.</p></div>
  25. <p></p>
  26. <p>The <code>WebSocket</code> object provides the API&nbsp;for creating and managing a <a title="en/WebSockets" rel="internal" href="https://developer.mozilla.org/en/WebSockets">WebSocket</a> connection to a server, as well as for sending and receiving data on the connection.</p><br><br>
  27. Documentation for this class was provided by <a href="https://developer.mozilla.org/en/WebSockets/WebSockets_reference/WebSocket">MDN</a>. */
  28. @:native("WebSocket")
  29. extern class WebSocket extends EventTarget
  30. {
  31. /** The connection is closed or couldn't be opened. */
  32. static inline var CLOSED : Int = 3;
  33. /** The connection is in the process of closing. */
  34. static inline var CLOSING : Int = 2;
  35. /** The connection is not yet open. */
  36. static inline var CONNECTING : Int = 0;
  37. /** The connection is open and ready to communicate. */
  38. static inline var OPEN : Int = 1;
  39. var URL(default,null) : String;
  40. /** A string indicating the type of binary data being transmitted by the connection. This should be either "blob"&nbsp;if DOM&nbsp;<code><a rel="custom" href="https://developer.mozilla.org/en/DOM/Blob">Blob</a></code>
  41. &nbsp;objects are being used or "arraybuffer" if <a title="en/JavaScript typed arrays/ArrayBuffer" rel="internal" href="https://developer.mozilla.org/en/JavaScript_typed_arrays/ArrayBuffer"><code>ArrayBuffer</code></a> objects are being used. */
  42. var binaryType : String;
  43. /** The number of bytes of data that have been queued using calls to but not yet transmitted to the network. This value does not reset to zero when the connection is closed; if you keep calling , this will continue to climb. <strong>Read only.</strong> */
  44. var bufferedAmount(default,null) : Int;
  45. /** The extensions selected by the server. This is currently only the empty string or a list of extensions as negotiated by the connection. */
  46. var extensions(default,null) : String;
  47. /** An event listener to be called when the WebSocket connection's <code>readyState</code> changes to <code>CLOSED</code>. The listener receives a <a title="en/WebSockets/WebSockets reference/CloseEvent" rel="internal" href="https://developer.mozilla.org/en/WebSockets/WebSockets_reference/CloseEvent"><code>CloseEvent</code></a> named "close". */
  48. var onclose : EventListener;
  49. /** An event listener to be called when an error occurs. This is a simple event named "error". */
  50. var onerror : EventListener;
  51. /** An event listener to be called when a message is received from the server. The listener receives a <a title="en/WebSockets/WebSockets reference/MessageEvent" rel="internal" href="https://developer.mozilla.org/en/WebSockets/WebSockets_reference/MessageEvent"><code>MessageEvent</code></a> named "message". */
  52. var onmessage : EventListener;
  53. /** An event listener to be called when the WebSocket connection's <code>readyState</code> changes to <code>OPEN</code>; this indicates that the connection is ready to send and receive data. The event is a simple one with the name "open". */
  54. var onopen : EventListener;
  55. /** A string indicating the name of the sub-protocol the server selected; this will be one of the strings specified in the <code>protocols</code> parameter when creating the WebSocket object. */
  56. var protocol(default,null) : String;
  57. /** The current state of the connection; this is one of the <a rel="custom" href="https://developer.mozilla.org/en/WebSockets/WebSockets_reference/WebSocket#Ready_state_constants">Ready state constants</a>. <strong>Read only.</strong> */
  58. var readyState(default,null) : Int;
  59. /** The URL&nbsp;as resolved by the constructor. This is always an absolute URL. <strong>Read only.</strong> */
  60. var url(default,null) : String;
  61. function new( ?arg0 : Dynamic ) : Void;
  62. function close( ?code : Int, ?reason : String ) : Void;
  63. /** <p>Transmits data to the server over the WebSocket connection.</p>
  64. <div id="section_11"><span id="Parameters_2"></span><h6 class="editable">Parameters</h6>
  65. <dl> <dt><code>data</code></dt> <dd>A text string to send to the server.</dd>
  66. </dl>
  67. </div><div id="section_12"><span id="Exceptions_thrown_2"></span><h6 class="editable">Exceptions thrown</h6>
  68. <dl> <dt><code>INVALID_STATE_ERR</code></dt> <dd>The connection is not currently <code>OPEN</code>.</dd> <dt><code>SYNTAX_ERR</code></dt> <dd>The data is a string that has unpaired surrogates.</dd>
  69. </dl>
  70. </div><div id="section_13"><span id="Remarks"></span><h6 class="editable">Remarks</h6>
  71. <div class="geckoVersionNote"> <p>
  72. </p><div class="geckoVersionHeading">Gecko 6.0 note<div>(Firefox 6.0 / Thunderbird 6.0 / SeaMonkey 2.3)
  73. </div></div>
  74. <p></p> <p>Gecko's implementation of the <code>send()</code>&nbsp;method differs somewhat from the specification in Gecko 6.0; Gecko returns a <code>boolean</code> indicating whether or not the connection is still open (and, by extension, that the data was successfully queued or transmitted); this is corrected in Gecko 8.0 (Firefox 8.0 / Thunderbird 8.0 / SeaMonkey 2.5)
  75. . In addition, at this time, Gecko does not support <code><a title="en/JavaScript typed arrays/ArrayBuffer" rel="internal" href="https://developer.mozilla.org/en/JavaScript_typed_arrays/ArrayBuffer">ArrayBuffer</a></code> or <code><a rel="custom" href="https://developer.mozilla.org/en/DOM/Blob">Blob</a></code>
  76. data types.</p>
  77. </div>
  78. </div> Throws DOMException. */
  79. @:overload( function( data : ArrayBuffer ) :Bool {} )
  80. @:overload( function( data : ArrayBufferView ) :Bool {} )
  81. @:overload( function( data : Blob ) :Bool {} )
  82. function send( data : String ) : Bool;
  83. }