diff --git a/docs/generated/assets/js/search.js b/docs/generated/assets/js/search.js index e60c521..1433e22 100644 --- a/docs/generated/assets/js/search.js +++ b/docs/generated/assets/js/search.js @@ -1,3 +1,3 @@ var typedoc = typedoc || {}; typedoc.search = typedoc.search || {}; - typedoc.search.data = {"kinds":{"64":"Function","256":"Interface","1024":"Property","2048":"Method"},"rows":[{"id":0,"kind":256,"name":"us_listen_socket","url":"interfaces/us_listen_socket.html","classes":"tsd-kind-interface tsd-is-not-exported"},{"id":1,"kind":256,"name":"HttpResponse","url":"interfaces/httpresponse.html","classes":"tsd-kind-interface tsd-is-not-exported"},{"id":2,"kind":2048,"name":"writeHeader","url":"interfaces/httpresponse.html#writeheader","classes":"tsd-kind-method tsd-parent-kind-interface tsd-is-not-exported","parent":"HttpResponse"},{"id":3,"kind":2048,"name":"end","url":"interfaces/httpresponse.html#end","classes":"tsd-kind-method tsd-parent-kind-interface tsd-is-not-exported","parent":"HttpResponse"},{"id":4,"kind":2048,"name":"tryEnd","url":"interfaces/httpresponse.html#tryend","classes":"tsd-kind-method tsd-parent-kind-interface tsd-is-not-exported","parent":"HttpResponse"},{"id":5,"kind":256,"name":"HttpRequest","url":"interfaces/httprequest.html","classes":"tsd-kind-interface tsd-is-not-exported"},{"id":6,"kind":2048,"name":"getHeader","url":"interfaces/httprequest.html#getheader","classes":"tsd-kind-method tsd-parent-kind-interface tsd-is-not-exported","parent":"HttpRequest"},{"id":7,"kind":256,"name":"TemplatedApp","url":"interfaces/templatedapp.html","classes":"tsd-kind-interface tsd-is-not-exported"},{"id":8,"kind":2048,"name":"listen","url":"interfaces/templatedapp.html#listen","classes":"tsd-kind-method tsd-parent-kind-interface tsd-is-not-exported","parent":"TemplatedApp"},{"id":9,"kind":2048,"name":"get","url":"interfaces/templatedapp.html#get","classes":"tsd-kind-method tsd-parent-kind-interface tsd-is-not-exported","parent":"TemplatedApp"},{"id":10,"kind":2048,"name":"post","url":"interfaces/templatedapp.html#post","classes":"tsd-kind-method tsd-parent-kind-interface tsd-is-not-exported","parent":"TemplatedApp"},{"id":11,"kind":256,"name":"AppOptions","url":"interfaces/appoptions.html","classes":"tsd-kind-interface tsd-is-not-exported"},{"id":12,"kind":1024,"name":"key_file_name","url":"interfaces/appoptions.html#key_file_name","classes":"tsd-kind-property tsd-parent-kind-interface tsd-is-not-exported","parent":"AppOptions"},{"id":13,"kind":1024,"name":"cert_file_name","url":"interfaces/appoptions.html#cert_file_name","classes":"tsd-kind-property tsd-parent-kind-interface tsd-is-not-exported","parent":"AppOptions"},{"id":14,"kind":1024,"name":"passphrase","url":"interfaces/appoptions.html#passphrase","classes":"tsd-kind-property tsd-parent-kind-interface tsd-is-not-exported","parent":"AppOptions"},{"id":15,"kind":64,"name":"App","url":"index.html#app","classes":"tsd-kind-function"},{"id":16,"kind":64,"name":"SSLApp","url":"index.html#sslapp","classes":"tsd-kind-function"}]}; \ No newline at end of file + typedoc.search.data = {"kinds":{"64":"Function","256":"Interface","1024":"Property","2048":"Method","65536":"Type literal"},"rows":[{"id":0,"kind":256,"name":"us_listen_socket","url":"interfaces/us_listen_socket.html","classes":"tsd-kind-interface tsd-is-not-exported"},{"id":1,"kind":256,"name":"WebSocket","url":"interfaces/websocket.html","classes":"tsd-kind-interface tsd-is-not-exported"},{"id":2,"kind":2048,"name":"send","url":"interfaces/websocket.html#send","classes":"tsd-kind-method tsd-parent-kind-interface tsd-is-not-exported","parent":"WebSocket"},{"id":3,"kind":2048,"name":"getBufferedAmount","url":"interfaces/websocket.html#getbufferedamount","classes":"tsd-kind-method tsd-parent-kind-interface tsd-is-not-exported","parent":"WebSocket"},{"id":4,"kind":2048,"name":"end","url":"interfaces/websocket.html#end","classes":"tsd-kind-method tsd-parent-kind-interface tsd-is-not-exported","parent":"WebSocket"},{"id":5,"kind":2048,"name":"close","url":"interfaces/websocket.html#close","classes":"tsd-kind-method tsd-parent-kind-interface tsd-is-not-exported","parent":"WebSocket"},{"id":6,"kind":2048,"name":"subscribe","url":"interfaces/websocket.html#subscribe","classes":"tsd-kind-method tsd-parent-kind-interface tsd-is-not-exported","parent":"WebSocket"},{"id":7,"kind":2048,"name":"publish","url":"interfaces/websocket.html#publish","classes":"tsd-kind-method tsd-parent-kind-interface tsd-is-not-exported","parent":"WebSocket"},{"id":8,"kind":2048,"name":"unsubscribe","url":"interfaces/websocket.html#unsubscribe","classes":"tsd-kind-method tsd-parent-kind-interface tsd-is-not-exported","parent":"WebSocket"},{"id":9,"kind":256,"name":"HttpResponse","url":"interfaces/httpresponse.html","classes":"tsd-kind-interface tsd-is-not-exported"},{"id":10,"kind":2048,"name":"writeStatus","url":"interfaces/httpresponse.html#writestatus","classes":"tsd-kind-method tsd-parent-kind-interface tsd-is-not-exported","parent":"HttpResponse"},{"id":11,"kind":2048,"name":"writeHeader","url":"interfaces/httpresponse.html#writeheader","classes":"tsd-kind-method tsd-parent-kind-interface tsd-is-not-exported","parent":"HttpResponse"},{"id":12,"kind":2048,"name":"write","url":"interfaces/httpresponse.html#write","classes":"tsd-kind-method tsd-parent-kind-interface tsd-is-not-exported","parent":"HttpResponse"},{"id":13,"kind":2048,"name":"end","url":"interfaces/httpresponse.html#end","classes":"tsd-kind-method tsd-parent-kind-interface tsd-is-not-exported","parent":"HttpResponse"},{"id":14,"kind":2048,"name":"tryEnd","url":"interfaces/httpresponse.html#tryend","classes":"tsd-kind-method tsd-parent-kind-interface tsd-is-not-exported","parent":"HttpResponse"},{"id":15,"kind":2048,"name":"close","url":"interfaces/httpresponse.html#close","classes":"tsd-kind-method tsd-parent-kind-interface tsd-is-not-exported","parent":"HttpResponse"},{"id":16,"kind":2048,"name":"getWriteOffset","url":"interfaces/httpresponse.html#getwriteoffset","classes":"tsd-kind-method tsd-parent-kind-interface tsd-is-not-exported","parent":"HttpResponse"},{"id":17,"kind":2048,"name":"onWritable","url":"interfaces/httpresponse.html#onwritable","classes":"tsd-kind-method tsd-parent-kind-interface tsd-is-not-exported","parent":"HttpResponse"},{"id":18,"kind":2048,"name":"onAborted","url":"interfaces/httpresponse.html#onaborted","classes":"tsd-kind-method tsd-parent-kind-interface tsd-is-not-exported","parent":"HttpResponse"},{"id":19,"kind":2048,"name":"onData","url":"interfaces/httpresponse.html#ondata","classes":"tsd-kind-method tsd-parent-kind-interface tsd-is-not-exported","parent":"HttpResponse"},{"id":20,"kind":256,"name":"HttpRequest","url":"interfaces/httprequest.html","classes":"tsd-kind-interface tsd-is-not-exported"},{"id":21,"kind":2048,"name":"getHeader","url":"interfaces/httprequest.html#getheader","classes":"tsd-kind-method tsd-parent-kind-interface tsd-is-not-exported","parent":"HttpRequest"},{"id":22,"kind":2048,"name":"getParameter","url":"interfaces/httprequest.html#getparameter","classes":"tsd-kind-method tsd-parent-kind-interface tsd-is-not-exported","parent":"HttpRequest"},{"id":23,"kind":2048,"name":"getUrl","url":"interfaces/httprequest.html#geturl","classes":"tsd-kind-method tsd-parent-kind-interface tsd-is-not-exported","parent":"HttpRequest"},{"id":24,"kind":2048,"name":"getMethod","url":"interfaces/httprequest.html#getmethod","classes":"tsd-kind-method tsd-parent-kind-interface tsd-is-not-exported","parent":"HttpRequest"},{"id":25,"kind":2048,"name":"getQuery","url":"interfaces/httprequest.html#getquery","classes":"tsd-kind-method tsd-parent-kind-interface tsd-is-not-exported","parent":"HttpRequest"},{"id":26,"kind":256,"name":"WebSocketBehavior","url":"interfaces/websocketbehavior.html","classes":"tsd-kind-interface tsd-is-not-exported"},{"id":27,"kind":1024,"name":"maxPayloadLength","url":"interfaces/websocketbehavior.html#maxpayloadlength","classes":"tsd-kind-property tsd-parent-kind-interface tsd-is-not-exported","parent":"WebSocketBehavior"},{"id":28,"kind":1024,"name":"idleTimeout","url":"interfaces/websocketbehavior.html#idletimeout","classes":"tsd-kind-property tsd-parent-kind-interface tsd-is-not-exported","parent":"WebSocketBehavior"},{"id":29,"kind":1024,"name":"compression","url":"interfaces/websocketbehavior.html#compression","classes":"tsd-kind-property tsd-parent-kind-interface tsd-is-not-exported","parent":"WebSocketBehavior"},{"id":30,"kind":1024,"name":"open","url":"interfaces/websocketbehavior.html#open","classes":"tsd-kind-property tsd-parent-kind-interface tsd-is-not-exported","parent":"WebSocketBehavior"},{"id":31,"kind":65536,"name":"__type","url":"interfaces/websocketbehavior.html#open.__type-3","classes":"tsd-kind-type-literal tsd-parent-kind-property tsd-is-not-exported","parent":"WebSocketBehavior.open"},{"id":32,"kind":1024,"name":"message","url":"interfaces/websocketbehavior.html#message","classes":"tsd-kind-property tsd-parent-kind-interface tsd-is-not-exported","parent":"WebSocketBehavior"},{"id":33,"kind":65536,"name":"__type","url":"interfaces/websocketbehavior.html#message.__type-2","classes":"tsd-kind-type-literal tsd-parent-kind-property tsd-is-not-exported","parent":"WebSocketBehavior.message"},{"id":34,"kind":1024,"name":"drain","url":"interfaces/websocketbehavior.html#drain","classes":"tsd-kind-property tsd-parent-kind-interface tsd-is-not-exported","parent":"WebSocketBehavior"},{"id":35,"kind":65536,"name":"__type","url":"interfaces/websocketbehavior.html#drain.__type-1","classes":"tsd-kind-type-literal tsd-parent-kind-property tsd-is-not-exported","parent":"WebSocketBehavior.drain"},{"id":36,"kind":1024,"name":"close","url":"interfaces/websocketbehavior.html#close","classes":"tsd-kind-property tsd-parent-kind-interface tsd-is-not-exported","parent":"WebSocketBehavior"},{"id":37,"kind":65536,"name":"__type","url":"interfaces/websocketbehavior.html#close.__type","classes":"tsd-kind-type-literal tsd-parent-kind-property tsd-is-not-exported","parent":"WebSocketBehavior.close"},{"id":38,"kind":256,"name":"AppOptions","url":"interfaces/appoptions.html","classes":"tsd-kind-interface tsd-is-not-exported"},{"id":39,"kind":1024,"name":"key_file_name","url":"interfaces/appoptions.html#key_file_name","classes":"tsd-kind-property tsd-parent-kind-interface tsd-is-not-exported","parent":"AppOptions"},{"id":40,"kind":1024,"name":"cert_file_name","url":"interfaces/appoptions.html#cert_file_name","classes":"tsd-kind-property tsd-parent-kind-interface tsd-is-not-exported","parent":"AppOptions"},{"id":41,"kind":1024,"name":"passphrase","url":"interfaces/appoptions.html#passphrase","classes":"tsd-kind-property tsd-parent-kind-interface tsd-is-not-exported","parent":"AppOptions"},{"id":42,"kind":1024,"name":"dh_params_file_name","url":"interfaces/appoptions.html#dh_params_file_name","classes":"tsd-kind-property tsd-parent-kind-interface tsd-is-not-exported","parent":"AppOptions"},{"id":43,"kind":256,"name":"TemplatedApp","url":"interfaces/templatedapp.html","classes":"tsd-kind-interface tsd-is-not-exported"},{"id":44,"kind":2048,"name":"listen","url":"interfaces/templatedapp.html#listen","classes":"tsd-kind-method tsd-parent-kind-interface tsd-is-not-exported","parent":"TemplatedApp"},{"id":45,"kind":2048,"name":"get","url":"interfaces/templatedapp.html#get","classes":"tsd-kind-method tsd-parent-kind-interface tsd-is-not-exported","parent":"TemplatedApp"},{"id":46,"kind":2048,"name":"post","url":"interfaces/templatedapp.html#post","classes":"tsd-kind-method tsd-parent-kind-interface tsd-is-not-exported","parent":"TemplatedApp"},{"id":47,"kind":2048,"name":"options","url":"interfaces/templatedapp.html#options","classes":"tsd-kind-method tsd-parent-kind-interface tsd-is-not-exported","parent":"TemplatedApp"},{"id":48,"kind":2048,"name":"del","url":"interfaces/templatedapp.html#del","classes":"tsd-kind-method tsd-parent-kind-interface tsd-is-not-exported","parent":"TemplatedApp"},{"id":49,"kind":2048,"name":"patch","url":"interfaces/templatedapp.html#patch","classes":"tsd-kind-method tsd-parent-kind-interface tsd-is-not-exported","parent":"TemplatedApp"},{"id":50,"kind":2048,"name":"put","url":"interfaces/templatedapp.html#put","classes":"tsd-kind-method tsd-parent-kind-interface tsd-is-not-exported","parent":"TemplatedApp"},{"id":51,"kind":2048,"name":"head","url":"interfaces/templatedapp.html#head","classes":"tsd-kind-method tsd-parent-kind-interface tsd-is-not-exported","parent":"TemplatedApp"},{"id":52,"kind":2048,"name":"connect","url":"interfaces/templatedapp.html#connect","classes":"tsd-kind-method tsd-parent-kind-interface tsd-is-not-exported","parent":"TemplatedApp"},{"id":53,"kind":2048,"name":"trace","url":"interfaces/templatedapp.html#trace","classes":"tsd-kind-method tsd-parent-kind-interface tsd-is-not-exported","parent":"TemplatedApp"},{"id":54,"kind":2048,"name":"any","url":"interfaces/templatedapp.html#any","classes":"tsd-kind-method tsd-parent-kind-interface tsd-is-not-exported","parent":"TemplatedApp"},{"id":55,"kind":2048,"name":"ws","url":"interfaces/templatedapp.html#ws","classes":"tsd-kind-method tsd-parent-kind-interface tsd-is-not-exported","parent":"TemplatedApp"},{"id":56,"kind":64,"name":"App","url":"index.html#app","classes":"tsd-kind-function"},{"id":57,"kind":64,"name":"SSLApp","url":"index.html#sslapp","classes":"tsd-kind-function"},{"id":58,"kind":64,"name":"us_listen_socket_close","url":"index.html#us_listen_socket_close","classes":"tsd-kind-function"}]}; \ No newline at end of file diff --git a/docs/generated/index.html b/docs/generated/index.html index 03ca8f1..7f490ac 100644 --- a/docs/generated/index.html +++ b/docs/generated/index.html @@ -72,6 +72,8 @@
  • HttpRequest
  • HttpResponse
  • TemplatedApp
  • +
  • WebSocket
  • +
  • WebSocketBehavior
  • us_listen_socket
  • @@ -80,6 +82,7 @@ @@ -97,7 +100,7 @@
  • @@ -125,7 +128,7 @@
  • @@ -143,6 +146,34 @@
  • +
    + +

    us_listen_socket_close

    + + +
    diff --git a/docs/generated/interfaces/appoptions.html b/docs/generated/interfaces/appoptions.html index 681d1f1..7a8e8fc 100644 --- a/docs/generated/interfaces/appoptions.html +++ b/docs/generated/interfaces/appoptions.html @@ -87,6 +87,7 @@

    Properties

    @@ -102,7 +103,17 @@
    cert_file_name: string
    + +
    + +

    Optional dh_params_file_name

    +
    dh_params_file_name: string
    +
    @@ -112,7 +123,7 @@
    key_file_name: string
    @@ -122,7 +133,7 @@
    passphrase: string
    @@ -146,6 +157,9 @@
  • cert_file_name
  • +
  • + dh_params_file_name +
  • key_file_name
  • @@ -165,6 +179,12 @@
  • TemplatedApp
  • +
  • + WebSocket +
  • +
  • + WebSocketBehavior +
  • us_listen_socket
  • @@ -174,6 +194,9 @@
  • SSLApp
  • +
  • + us_listen_socket_close +
  • diff --git a/docs/generated/interfaces/httprequest.html b/docs/generated/interfaces/httprequest.html index bc58a7a..233c2e4 100644 --- a/docs/generated/interfaces/httprequest.html +++ b/docs/generated/interfaces/httprequest.html @@ -87,6 +87,10 @@

    Methods

    @@ -104,9 +108,14 @@
  • +
    +
    +

    Returns the lowercased header value or empty string.

    +
    +

    Parameters

    +
    + +

    getMethod

    + + +
    +
    + +

    getParameter

    + + +
    +
    + +

    getQuery

    + + +
    +
    + +

    getUrl

    + + +
  • getHeader
  • +
  • + getMethod +
  • +
  • + getParameter +
  • +
  • + getQuery +
  • +
  • + getUrl +
  • @@ -150,6 +265,12 @@
  • TemplatedApp
  • +
  • + WebSocket +
  • +
  • + WebSocketBehavior +
  • us_listen_socket
  • @@ -159,6 +280,9 @@
  • SSLApp
  • +
  • + us_listen_socket_close +
  • diff --git a/docs/generated/interfaces/httpresponse.html b/docs/generated/interfaces/httpresponse.html index 84500b0..54245d9 100644 --- a/docs/generated/interfaces/httpresponse.html +++ b/docs/generated/interfaces/httpresponse.html @@ -86,9 +86,16 @@

    Methods

    @@ -97,16 +104,38 @@

    Methods

    - -

    end

    + +

    close

    +
    +
    + +

    end

    + + +
    +
    + +

    getWriteOffset

    + + +
    +
    + +

    onAborted

    + + +
    +
    + +

    onData

    + + +
    +
    + +

    onWritable

    + +
    @@ -134,7 +334,7 @@
  • @@ -156,28 +356,89 @@
  • - -

    writeHeader

    + +

    write

    +
    +
    + +

    writeHeader

    + + +
    +
    + +

    writeStatus

    + +
    @@ -204,15 +465,36 @@
  • HttpResponse
  • @@ -220,6 +502,12 @@
  • TemplatedApp
  • +
  • + WebSocket +
  • +
  • + WebSocketBehavior +
  • us_listen_socket
  • @@ -229,6 +517,9 @@
  • SSLApp
  • +
  • + us_listen_socket_close +
  • diff --git a/docs/generated/interfaces/templatedapp.html b/docs/generated/interfaces/templatedapp.html index a25dc6e..2ec313b 100644 --- a/docs/generated/interfaces/templatedapp.html +++ b/docs/generated/interfaces/templatedapp.html @@ -86,9 +86,18 @@

    Methods

    @@ -96,6 +105,162 @@

    Methods

    +
    + +

    any

    + + +
    +
    + +

    connect

    + + +
    +
    + +

    del

    + + +

    get

    @@ -106,7 +271,7 @@
  • @@ -148,6 +313,58 @@
  • +
    + +

    head

    + + +

    listen

    @@ -159,7 +376,7 @@
  • @@ -202,7 +419,7 @@
  • @@ -241,6 +458,110 @@
  • +
    + +

    options

    + + +
    +
    + +

    patch

    + + +

    post

    @@ -251,7 +572,7 @@
  • @@ -293,6 +614,141 @@
  • +
    + +

    put

    + + +
    +
    + +

    trace

    + + +
    +
    + +

    ws

    + + +
    diff --git a/docs/generated/interfaces/us_listen_socket.html b/docs/generated/interfaces/us_listen_socket.html index 20b4de1..788e504 100644 --- a/docs/generated/interfaces/us_listen_socket.html +++ b/docs/generated/interfaces/us_listen_socket.html @@ -102,6 +102,12 @@
  • TemplatedApp
  • +
  • + WebSocket +
  • +
  • + WebSocketBehavior +
  • diff --git a/docs/generated/interfaces/websocket.html b/docs/generated/interfaces/websocket.html new file mode 100644 index 0000000..f1196c2 --- /dev/null +++ b/docs/generated/interfaces/websocket.html @@ -0,0 +1,439 @@ + + + + + + WebSocket | uWebSockets.js v15.1.0 documentation (WIP & incomplete) + + + + + +
    +
    +
    +
    + +
    +
    + Options +
    +
    + All +
      +
    • Public
    • +
    • Public/Protected
    • +
    • All
    • +
    +
    + + + + +
    +
    + Menu +
    +
    +
    +
    +
    +
    + +

    Interface WebSocket

    +
    +
    +
    +
    +
    +
    +
    +
    +
    +

    A WebSocket connection that is valid from open to close event

    +
    +
    +
    +
    +

    Hierarchy

    +
      +
    • + WebSocket +
    • +
    +
    +
    +

    Index

    +
    +
    +
    +

    Methods

    + +
    +
    +
    +
    +
    +

    Methods

    +
    + +

    close

    + +
      +
    • + +
      +
      +

      Forefully closes this WebSocket. Immediately calls close handler.

      +
      +
      +

      Returns WebSocket

      +
    • +
    +
    +
    + +

    end

    +
      +
    • end(code: number, shortMessage: string | ArrayBuffer): WebSocket
    • +
    +
      +
    • + +
      +
      +

      Gradefully closes this WebSocket. Immediately calls close handler.

      +
      +
      +

      Parameters

      +
        +
      • +
        code: number
        +
      • +
      • +
        shortMessage: string | ArrayBuffer
        +
      • +
      +

      Returns WebSocket

      +
    • +
    +
    +
    + +

    getBufferedAmount

    +
      +
    • getBufferedAmount(): number
    • +
    +
      +
    • + +
      +
      +

      Returns the bytes buffered in backpressure.

      +
      +
      +

      Returns number

      +
    • +
    +
    +
    + +

    publish

    +
      +
    • publish(topic: string | ArrayBuffer, message: string | ArrayBuffer): WebSocket
    • +
    +
      +
    • + +
      +
      +

      Publish a message to a topic in MQTT syntax

      +
      +
      +

      Parameters

      +
        +
      • +
        topic: string | ArrayBuffer
        +
      • +
      • +
        message: string | ArrayBuffer
        +
      • +
      +

      Returns WebSocket

      +
    • +
    +
    +
    + +

    send

    +
      +
    • send(message: string | ArrayBuffer, isBinary: boolean, compress: boolean): boolean
    • +
    +
      +
    • + +
      +
      +

      Sends a message. Make sure to check getBufferedAmount() before sending. Returns true for success, false for built up backpressure that will drain when time is given.

      +
      +
      +

      Parameters

      +
        +
      • +
        message: string | ArrayBuffer
        +
      • +
      • +
        isBinary: boolean
        +
      • +
      • +
        compress: boolean
        +
      • +
      +

      Returns boolean

      +
    • +
    +
    +
    + +

    subscribe

    +
      +
    • subscribe(topic: string | ArrayBuffer): WebSocket
    • +
    +
      +
    • + +
      +
      +

      Subscribe to a topic in MQTT syntax

      +
      +
      +

      Parameters

      +
        +
      • +
        topic: string | ArrayBuffer
        +
      • +
      +

      Returns WebSocket

      +
    • +
    +
    +
    + +

    unsubscribe

    +
      +
    • unsubscribe(topic: string | ArrayBuffer): WebSocket
    • +
    +
      +
    • + +
      +
      +

      Unsubscribe from topic (not implemented yet)

      +
      +
      +

      Parameters

      +
        +
      • +
        topic: string | ArrayBuffer
        +
      • +
      +

      Returns WebSocket

      +
    • +
    +
    +
    +
    + +
    +
    + +
    +

    Generated using TypeDoc

    +
    +
    + + + + \ No newline at end of file diff --git a/docs/generated/interfaces/websocketbehavior.html b/docs/generated/interfaces/websocketbehavior.html new file mode 100644 index 0000000..f448c08 --- /dev/null +++ b/docs/generated/interfaces/websocketbehavior.html @@ -0,0 +1,447 @@ + + + + + + WebSocketBehavior | uWebSockets.js v15.1.0 documentation (WIP & incomplete) + + + + + +
    +
    +
    +
    + +
    +
    + Options +
    +
    + All +
      +
    • Public
    • +
    • Public/Protected
    • +
    • All
    • +
    +
    + + + + +
    +
    + Menu +
    +
    +
    +
    +
    +
    + +

    Interface WebSocketBehavior

    +
    +
    +
    +
    +
    +
    +
    +
    +
    +

    A structure holding settings and handlers for a WebSocket route handler.

    +
    +
    +
    +
    +

    Hierarchy

    +
      +
    • + WebSocketBehavior +
    • +
    +
    +
    +

    Index

    +
    +
    +
    +

    Properties

    + +
    +
    +
    +
    +
    +

    Properties

    +
    + +

    Optional close

    +
    close: function
    + +
    +
    +

    Handler for close event, no matter if error, timeout or graceful close. You may not use WebSocket after this event.

    +
    +
    +
    +

    Type declaration

    +
      +
    • +
        +
      • (ws: WebSocket, code: number, message: ArrayBuffer): void
      • +
      +
        +
      • +

        Parameters

        +
          +
        • +
          ws: WebSocket
          +
        • +
        • +
          code: number
          +
        • +
        • +
          message: ArrayBuffer
          +
        • +
        +

        Returns void

        +
      • +
      +
    • +
    +
    +
    +
    + +

    Optional compression

    +
    compression: number
    + +
    +
    +

    0 = no compression, 1 = shared compressor, 2 = dedicated compressor. See C++ project.

    +
    +
    +
    +
    + +

    Optional drain

    +
    drain: function
    + +
    +
    +

    Handler for when WebSocket backpressure drains. Check ws.getBufferedAmount().

    +
    +
    +
    +

    Type declaration

    +
      +
    • + +
        +
      • +

        Parameters

        + +

        Returns void

        +
      • +
      +
    • +
    +
    +
    +
    + +

    Optional idleTimeout

    +
    idleTimeout: number
    + +
    +
    +

    Maximum amount of seconds that may pass without sending or getting a message.

    +
    +
    +
    +
    + +

    Optional maxPayloadLength

    +
    maxPayloadLength: number
    + +
    +
    +

    Maximum length of received message.

    +
    +
    +
    +
    + +

    Optional message

    +
    message: function
    + +
    +
    +

    Handler for a WebSocket message.

    +
    +
    +
    +

    Type declaration

    +
      +
    • +
        +
      • (ws: WebSocket, message: ArrayBuffer, isBinary: boolean): void
      • +
      +
        +
      • +

        Parameters

        +
          +
        • +
          ws: WebSocket
          +
        • +
        • +
          message: ArrayBuffer
          +
        • +
        • +
          isBinary: boolean
          +
        • +
        +

        Returns void

        +
      • +
      +
    • +
    +
    +
    +
    + +

    Optional open

    +
    open: function
    + +
    +
    +

    Handler for new WebSocket connection. WebSocket is valid from open to close, no errors.

    +
    +
    +
    +

    Type declaration

    + +
    +
    +
    +
    + +
    +
    + +
    +

    Generated using TypeDoc

    +
    +
    + + + + \ No newline at end of file diff --git a/docs/index.d.ts b/docs/index.d.ts index bb12871..75c1864 100644 --- a/docs/index.d.ts +++ b/docs/index.d.ts @@ -5,18 +5,103 @@ interface us_listen_socket { } +/** A WebSocket connection that is valid from open to close event */ +interface WebSocket { + /** Sends a message. Make sure to check getBufferedAmount() before sending. Returns true for success, false for built up backpressure that will drain when time is given. */ + send(message: string | ArrayBuffer, isBinary: boolean, compress: boolean) : boolean; + + /** Returns the bytes buffered in backpressure. */ + getBufferedAmount() : number; + + /** Gradefully closes this WebSocket. Immediately calls close handler. */ + end(code: number, shortMessage: string | ArrayBuffer) : WebSocket; + + /** Forefully closes this WebSocket. Immediately calls close handler. */ + close() : WebSocket; + + /** Subscribe to a topic in MQTT syntax */ + subscribe(topic: string | ArrayBuffer) : WebSocket; + + /** Publish a message to a topic in MQTT syntax */ + publish(topic: string | ArrayBuffer, message: string | ArrayBuffer) : WebSocket; + + /** Unsubscribe from topic (not implemented yet) */ + unsubscribe(topic: string | ArrayBuffer) : WebSocket; +} + /** An HttpResponse is valid until either onAborted callback or any of the .end/.tryEnd calls succeed. You may attach user data to this object. */ interface HttpResponse { - writeHeader(key: string, value: string) : void; + /** Writes the HTTP status message such as "200 OK". */ + writeStatus(status: string | ArrayBuffer) : HttpResponse; + /** Writes key and value to HTTP response. */ + writeHeader(key: string | ArrayBuffer, value: string | ArrayBuffer) : HttpResponse; + /** Enters or continues chunked encoding mode. Writes part of the response. End with zero length write. */ + write(chunk: string | ArrayBuffer) : HttpResponse; /** Ends this response by copying the contents of body. */ - end(body: string) : void; + end(body: string | ArrayBuffer) : HttpResponse; /** Ends this response, or tries to, by streaming appropriately sized chunks of body. Use in conjunction with onWritable. Returns tuple [ok, hasResponded].*/ tryEnd(fullBodyOrChunk: string, totalSize: number) : [boolean, boolean]; + + /** Immediately force closes the connection. */ + close() : HttpResponse; + + /** Returns the global byte write offset for this response. Use with onWritable. */ + getWriteOffset() : number; + + /** Registers a handler for writable events. Continue failed write attempts in here. + * You MUST return true for success, false for failure. + * Writing nothing is always success, so by default you must return true. + */ + onWritable(handler: (res: HttpResponse) => boolean) : HttpResponse; + + /** Every HttpResponse MUST have an attached abort handler IF you do not respond + * to it immediately inside of the callback. Returning from an Http request handler + * without attaching (by calling onAborted) an abort handler is ill-use and will termiante. + * When this event emits, the response has been aborted and may not be used. */ + onAborted(handler: (res: HttpResponse) => void) : HttpResponse; + + /** Handler for reading data from POST and such requests. You MUST copy the data of chunk if isLast is not true. We Neuter ArrayBuffers on return, making it zero length.*/ + onData(handler: (res: HttpResponse, chunk: ArrayBuffer, isLast: boolean) => void) : HttpResponse; } /** An HttpRequest is stack allocated and only accessible during the callback invocation. */ interface HttpRequest { + /** Returns the lowercased header value or empty string. */ getHeader(lowerCaseKey: string) : string; + /** Returns the parsed parameter at index. Corresponds to route. */ + getParameter(index: number) : string; + /** Returns the URL including initial /slash */ + getUrl() : string; + /** Returns the HTTP method, useful for "any" routes. */ + getMethod() : string; + /** Returns the part of URL after ? sign or empty string. */ + getQuery() : string; +} + +/** A structure holding settings and handlers for a WebSocket route handler. */ +interface WebSocketBehavior { + /** Maximum length of received message. */ + maxPayloadLength?: number; + /** Maximum amount of seconds that may pass without sending or getting a message. */ + idleTimeout?: number; + /** 0 = no compression, 1 = shared compressor, 2 = dedicated compressor. See C++ project. */ + compression?: number; + /** Handler for new WebSocket connection. WebSocket is valid from open to close, no errors. */ + open?: (ws: WebSocket, req: HttpRequest) => void; + /** Handler for a WebSocket message. */ + message?: (ws: WebSocket, message: ArrayBuffer, isBinary: boolean) => void; + /** Handler for when WebSocket backpressure drains. Check ws.getBufferedAmount(). */ + drain?: (ws: WebSocket) => void; + /** Handler for close event, no matter if error, timeout or graceful close. You may not use WebSocket after this event. */ + close?: (ws: WebSocket, code: number, message: ArrayBuffer) => void; +} + +/** Options used when constructing an app. */ +interface AppOptions { + key_file_name?: string; + cert_file_name?: string; + passphrase?: string; + dh_params_file_name?: string; } /** TemplatedApp is either an SSL or non-SSL app. */ @@ -29,13 +114,24 @@ interface TemplatedApp { get(pattern: string, handler: (res: HttpResponse, req: HttpRequest) => void) : TemplatedApp; /** Registers an HTTP POST handler matching specified URL pattern. */ post(pattern: string, handler: (res: HttpResponse, req: HttpRequest) => void) : TemplatedApp; -} - -/** Options used when constructing an app. */ -interface AppOptions { - key_file_name?: string - cert_file_name?: string - passphrase?: string + /** Registers an HTTP OPTIONS handler matching specified URL pattern. */ + options(pattern: string, handler: (res: HttpResponse, req: HttpRequest) => void) : TemplatedApp; + /** Registers an HTTP DELETE handler matching specified URL pattern. */ + del(pattern: string, handler: (res: HttpResponse, req: HttpRequest) => void) : TemplatedApp; + /** Registers an HTTP PATCH handler matching specified URL pattern. */ + patch(pattern: string, handler: (res: HttpResponse, req: HttpRequest) => void) : TemplatedApp; + /** Registers an HTTP PUT handler matching specified URL pattern. */ + put(pattern: string, handler: (res: HttpResponse, req: HttpRequest) => void) : TemplatedApp; + /** Registers an HTTP HEAD handler matching specified URL pattern. */ + head(pattern: string, handler: (res: HttpResponse, req: HttpRequest) => void) : TemplatedApp; + /** Registers an HTTP CONNECT handler matching specified URL pattern. */ + connect(pattern: string, handler: (res: HttpResponse, req: HttpRequest) => void) : TemplatedApp; + /** Registers an HTTP TRACE handler matching specified URL pattern. */ + trace(pattern: string, handler: (res: HttpResponse, req: HttpRequest) => void) : TemplatedApp; + /** Registers an HTTP handler matching specified URL pattern on any HTTP method. */ + any(pattern: string, handler: (res: HttpResponse, req: HttpRequest) => void) : TemplatedApp; + /** Registers a handler matching specified URL pattern where WebSocket upgrade requests are caught. */ + ws(pattern: string, behavior: WebSocketBehavior) : TemplatedApp; } /** Constructs a non-SSL app */ @@ -43,3 +139,6 @@ export function App(options: AppOptions): TemplatedApp; /** Constructs an SSL app */ export function SSLApp(options: AppOptions): TemplatedApp; + +/** Closes a uSockets listen socket. */ +export function us_listen_socket_close(listenSocket: us_listen_socket): void;