change websocket publish to return boolean as the uws method publish returns boolean (#641)
* Update docs to match implementation * change websocket publish to return boolean as the uws method publish returns boolean * re-generate typedoc since publish changed to return boolean
This commit is contained in:
parent
2f829d1b36
commit
bce99d8884
@ -4,7 +4,7 @@
|
||||
<p>Arbitrary user data may be attached to this object</p>
|
||||
</div></div></section><section class="tsd-panel-group tsd-index-group"><h2>Index</h2><section class="tsd-panel tsd-index-panel"><div class="tsd-index-content"><section class="tsd-index-section "><h3>Methods</h3><ul class="tsd-index-list"><li class="tsd-kind-method tsd-parent-kind-interface"><a href="HttpResponse.html#close" class="tsd-kind-icon">close</a></li><li class="tsd-kind-method tsd-parent-kind-interface"><a href="HttpResponse.html#cork" class="tsd-kind-icon">cork</a></li><li class="tsd-kind-method tsd-parent-kind-interface"><a href="HttpResponse.html#end" class="tsd-kind-icon">end</a></li><li class="tsd-kind-method tsd-parent-kind-interface"><a href="HttpResponse.html#getProxiedRemoteAddress" class="tsd-kind-icon">get<wbr/>Proxied<wbr/>Remote<wbr/>Address</a></li><li class="tsd-kind-method tsd-parent-kind-interface"><a href="HttpResponse.html#getProxiedRemoteAddressAsText" class="tsd-kind-icon">get<wbr/>Proxied<wbr/>Remote<wbr/>Address<wbr/>As<wbr/>Text</a></li><li class="tsd-kind-method tsd-parent-kind-interface"><a href="HttpResponse.html#getRemoteAddress" class="tsd-kind-icon">get<wbr/>Remote<wbr/>Address</a></li><li class="tsd-kind-method tsd-parent-kind-interface"><a href="HttpResponse.html#getRemoteAddressAsText" class="tsd-kind-icon">get<wbr/>Remote<wbr/>Address<wbr/>As<wbr/>Text</a></li><li class="tsd-kind-method tsd-parent-kind-interface"><a href="HttpResponse.html#getWriteOffset" class="tsd-kind-icon">get<wbr/>Write<wbr/>Offset</a></li><li class="tsd-kind-method tsd-parent-kind-interface"><a href="HttpResponse.html#onAborted" class="tsd-kind-icon">on<wbr/>Aborted</a></li><li class="tsd-kind-method tsd-parent-kind-interface"><a href="HttpResponse.html#onData" class="tsd-kind-icon">on<wbr/>Data</a></li><li class="tsd-kind-method tsd-parent-kind-interface"><a href="HttpResponse.html#onWritable" class="tsd-kind-icon">on<wbr/>Writable</a></li><li class="tsd-kind-method tsd-parent-kind-interface"><a href="HttpResponse.html#tryEnd" class="tsd-kind-icon">try<wbr/>End</a></li><li class="tsd-kind-method tsd-parent-kind-interface tsd-has-type-parameter"><a href="HttpResponse.html#upgrade" class="tsd-kind-icon">upgrade</a></li><li class="tsd-kind-method tsd-parent-kind-interface"><a href="HttpResponse.html#write" class="tsd-kind-icon">write</a></li><li class="tsd-kind-method tsd-parent-kind-interface"><a href="HttpResponse.html#writeHeader" class="tsd-kind-icon">write<wbr/>Header</a></li><li class="tsd-kind-method tsd-parent-kind-interface"><a href="HttpResponse.html#writeStatus" class="tsd-kind-icon">write<wbr/>Status</a></li></ul></section></div></section></section><section class="tsd-panel-group tsd-member-group "><h2>Methods</h2><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-interface"><a id="close" class="tsd-anchor"></a><h3>close</h3><ul class="tsd-signatures tsd-kind-method tsd-parent-kind-interface"><li class="tsd-signature tsd-kind-icon">close<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="HttpResponse.html" class="tsd-signature-type" data-tsd-kind="Interface">HttpResponse</a></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/uNetworking/uWebSockets.js/blob/master/docs/index.d.ts#L141">index.d.ts:141</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
|
||||
<p>Immediately force closes the connection. Any onAborted callback will run.</p>
|
||||
</div></div><h4 class="tsd-returns-title">Returns <a href="HttpResponse.html" class="tsd-signature-type" data-tsd-kind="Interface">HttpResponse</a></h4></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-interface"><a id="cork" class="tsd-anchor"></a><h3>cork</h3><ul class="tsd-signatures tsd-kind-method tsd-parent-kind-interface"><li class="tsd-signature tsd-kind-icon">cork<span class="tsd-signature-symbol">(</span>cb<span class="tsd-signature-symbol">: </span><span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol"> => </span><span class="tsd-signature-type">void</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">void</span></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/uNetworking/uWebSockets.js/blob/master/docs/index.d.ts#L186">index.d.ts:186</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
|
||||
</div></div><h4 class="tsd-returns-title">Returns <a href="HttpResponse.html" class="tsd-signature-type" data-tsd-kind="Interface">HttpResponse</a></h4></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-interface"><a id="cork" class="tsd-anchor"></a><h3>cork</h3><ul class="tsd-signatures tsd-kind-method tsd-parent-kind-interface"><li class="tsd-signature tsd-kind-icon">cork<span class="tsd-signature-symbol">(</span>cb<span class="tsd-signature-symbol">: </span><span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol"> => </span><span class="tsd-signature-type">void</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="HttpResponse.html" class="tsd-signature-type" data-tsd-kind="Interface">HttpResponse</a></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/uNetworking/uWebSockets.js/blob/master/docs/index.d.ts#L186">index.d.ts:186</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
|
||||
<p>Corking a response is a performance improvement in both CPU and network, as you ready the IO system for writing multiple chunks at once.
|
||||
By default, you're corked in the immediately executing top portion of the route handler. In all other cases, such as when returning from
|
||||
await, or when being called back from an async database request or anything that isn't directly executing in the route handler, you'll want
|
||||
@ -15,7 +15,7 @@ in one TLS block being sent off, each with one send syscall.</p>
|
||||
<p>res.cork(() => {
|
||||
res.writeStatus("200 OK").writeHeader("Some", "Value").write("Hello world!");
|
||||
});</p>
|
||||
</div></div><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5>cb: <span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol"> => </span><span class="tsd-signature-type">void</span></h5><ul class="tsd-parameters"><li class="tsd-parameter-signature"><ul class="tsd-signatures tsd-kind-type-literal"><li class="tsd-signature tsd-kind-icon"><span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">void</span></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</span></h4></li></ul></li></ul></li></ul><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</span></h4></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-interface"><a id="end" class="tsd-anchor"></a><h3>end</h3><ul class="tsd-signatures tsd-kind-method tsd-parent-kind-interface"><li class="tsd-signature tsd-kind-icon">end<span class="tsd-signature-symbol">(</span>body<span class="tsd-signature-symbol">?: </span><a href="../index.html#RecognizedString" class="tsd-signature-type" data-tsd-kind="Type alias">RecognizedString</a>, closeConnection<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">boolean</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="HttpResponse.html" class="tsd-signature-type" data-tsd-kind="Interface">HttpResponse</a></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/uNetworking/uWebSockets.js/blob/master/docs/index.d.ts#L136">index.d.ts:136</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
|
||||
</div></div><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5>cb: <span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol"> => </span><span class="tsd-signature-type">void</span></h5><ul class="tsd-parameters"><li class="tsd-parameter-signature"><ul class="tsd-signatures tsd-kind-type-literal"><li class="tsd-signature tsd-kind-icon"><span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">void</span></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</span></h4></li></ul></li></ul></li></ul><h4 class="tsd-returns-title">Returns <a href="HttpResponse.html" class="tsd-signature-type" data-tsd-kind="Interface">HttpResponse</a></h4></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-interface"><a id="end" class="tsd-anchor"></a><h3>end</h3><ul class="tsd-signatures tsd-kind-method tsd-parent-kind-interface"><li class="tsd-signature tsd-kind-icon">end<span class="tsd-signature-symbol">(</span>body<span class="tsd-signature-symbol">?: </span><a href="../index.html#RecognizedString" class="tsd-signature-type" data-tsd-kind="Type alias">RecognizedString</a>, closeConnection<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">boolean</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="HttpResponse.html" class="tsd-signature-type" data-tsd-kind="Interface">HttpResponse</a></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/uNetworking/uWebSockets.js/blob/master/docs/index.d.ts#L136">index.d.ts:136</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
|
||||
<p>Ends this response by copying the contents of body.</p>
|
||||
</div></div><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5><span class="tsd-flag ts-flagOptional">Optional</span> body: <a href="../index.html#RecognizedString" class="tsd-signature-type" data-tsd-kind="Type alias">RecognizedString</a></h5></li><li><h5><span class="tsd-flag ts-flagOptional">Optional</span> closeConnection: <span class="tsd-signature-type">boolean</span></h5></li></ul><h4 class="tsd-returns-title">Returns <a href="HttpResponse.html" class="tsd-signature-type" data-tsd-kind="Interface">HttpResponse</a></h4></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-interface"><a id="getProxiedRemoteAddress" class="tsd-anchor"></a><h3>get<wbr/>Proxied<wbr/>Remote<wbr/>Address</h3><ul class="tsd-signatures tsd-kind-method tsd-parent-kind-interface"><li class="tsd-signature tsd-kind-icon">get<wbr/>Proxied<wbr/>Remote<wbr/>Address<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">ArrayBuffer</span></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/uNetworking/uWebSockets.js/blob/master/docs/index.d.ts#L168">index.d.ts:168</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
|
||||
<p>Returns the remote IP address in binary format (4 or 16 bytes), as reported by the PROXY Protocol v2 compatible proxy.</p>
|
||||
|
@ -3,15 +3,15 @@
|
||||
Read more about this in the user manual.</p>
|
||||
</div></div></section><section class="tsd-panel tsd-hierarchy"><h3>Hierarchy</h3><ul class="tsd-hierarchy"><li><span class="target">WebSocket</span></li></ul></section><section class="tsd-panel tsd-kind-interface"><h3 class="tsd-before-signature">Indexable</h3><div class="tsd-signature tsd-kind-icon"><span class="tsd-signature-symbol">[</span>key: <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">]: </span><span class="tsd-signature-type">any</span></div><div class="tsd-comment tsd-typography"><div class="lead">
|
||||
<p>Arbitrary user data may be attached to this object. In C++ this is done by using getUserData().</p>
|
||||
</div></div></section><section class="tsd-panel-group tsd-index-group"><h2>Index</h2><section class="tsd-panel tsd-index-panel"><div class="tsd-index-content"><section class="tsd-index-section "><h3>Methods</h3><ul class="tsd-index-list"><li class="tsd-kind-method tsd-parent-kind-interface"><a href="WebSocket.html#close" class="tsd-kind-icon">close</a></li><li class="tsd-kind-method tsd-parent-kind-interface"><a href="WebSocket.html#cork" class="tsd-kind-icon">cork</a></li><li class="tsd-kind-method tsd-parent-kind-interface"><a href="WebSocket.html#end" class="tsd-kind-icon">end</a></li><li class="tsd-kind-method tsd-parent-kind-interface"><a href="WebSocket.html#getBufferedAmount" class="tsd-kind-icon">get<wbr/>Buffered<wbr/>Amount</a></li><li class="tsd-kind-method tsd-parent-kind-interface"><a href="WebSocket.html#getRemoteAddress" class="tsd-kind-icon">get<wbr/>Remote<wbr/>Address</a></li><li class="tsd-kind-method tsd-parent-kind-interface"><a href="WebSocket.html#getRemoteAddressAsText" class="tsd-kind-icon">get<wbr/>Remote<wbr/>Address<wbr/>As<wbr/>Text</a></li><li class="tsd-kind-method tsd-parent-kind-interface"><a href="WebSocket.html#getTopics" class="tsd-kind-icon">get<wbr/>Topics</a></li><li class="tsd-kind-method tsd-parent-kind-interface"><a href="WebSocket.html#isSubscribed" class="tsd-kind-icon">is<wbr/>Subscribed</a></li><li class="tsd-kind-method tsd-parent-kind-interface"><a href="WebSocket.html#ping" class="tsd-kind-icon">ping</a></li><li class="tsd-kind-method tsd-parent-kind-interface"><a href="WebSocket.html#publish" class="tsd-kind-icon">publish</a></li><li class="tsd-kind-method tsd-parent-kind-interface"><a href="WebSocket.html#send" class="tsd-kind-icon">send</a></li><li class="tsd-kind-method tsd-parent-kind-interface"><a href="WebSocket.html#subscribe" class="tsd-kind-icon">subscribe</a></li><li class="tsd-kind-method tsd-parent-kind-interface"><a href="WebSocket.html#unsubscribe" class="tsd-kind-icon">unsubscribe</a></li></ul></section></div></section></section><section class="tsd-panel-group tsd-member-group "><h2>Methods</h2><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-interface"><a id="close" class="tsd-anchor"></a><h3>close</h3><ul class="tsd-signatures tsd-kind-method tsd-parent-kind-interface"><li class="tsd-signature tsd-kind-icon">close<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="WebSocket.html" class="tsd-signature-type" data-tsd-kind="Interface">WebSocket</a></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/uNetworking/uWebSockets.js/blob/master/docs/index.d.ts#L71">index.d.ts:71</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
|
||||
</div></div></section><section class="tsd-panel-group tsd-index-group"><h2>Index</h2><section class="tsd-panel tsd-index-panel"><div class="tsd-index-content"><section class="tsd-index-section "><h3>Methods</h3><ul class="tsd-index-list"><li class="tsd-kind-method tsd-parent-kind-interface"><a href="WebSocket.html#close" class="tsd-kind-icon">close</a></li><li class="tsd-kind-method tsd-parent-kind-interface"><a href="WebSocket.html#cork" class="tsd-kind-icon">cork</a></li><li class="tsd-kind-method tsd-parent-kind-interface"><a href="WebSocket.html#end" class="tsd-kind-icon">end</a></li><li class="tsd-kind-method tsd-parent-kind-interface"><a href="WebSocket.html#getBufferedAmount" class="tsd-kind-icon">get<wbr/>Buffered<wbr/>Amount</a></li><li class="tsd-kind-method tsd-parent-kind-interface"><a href="WebSocket.html#getRemoteAddress" class="tsd-kind-icon">get<wbr/>Remote<wbr/>Address</a></li><li class="tsd-kind-method tsd-parent-kind-interface"><a href="WebSocket.html#getRemoteAddressAsText" class="tsd-kind-icon">get<wbr/>Remote<wbr/>Address<wbr/>As<wbr/>Text</a></li><li class="tsd-kind-method tsd-parent-kind-interface"><a href="WebSocket.html#getTopics" class="tsd-kind-icon">get<wbr/>Topics</a></li><li class="tsd-kind-method tsd-parent-kind-interface"><a href="WebSocket.html#isSubscribed" class="tsd-kind-icon">is<wbr/>Subscribed</a></li><li class="tsd-kind-method tsd-parent-kind-interface"><a href="WebSocket.html#ping" class="tsd-kind-icon">ping</a></li><li class="tsd-kind-method tsd-parent-kind-interface"><a href="WebSocket.html#publish" class="tsd-kind-icon">publish</a></li><li class="tsd-kind-method tsd-parent-kind-interface"><a href="WebSocket.html#send" class="tsd-kind-icon">send</a></li><li class="tsd-kind-method tsd-parent-kind-interface"><a href="WebSocket.html#subscribe" class="tsd-kind-icon">subscribe</a></li><li class="tsd-kind-method tsd-parent-kind-interface"><a href="WebSocket.html#unsubscribe" class="tsd-kind-icon">unsubscribe</a></li></ul></section></div></section></section><section class="tsd-panel-group tsd-member-group "><h2>Methods</h2><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-interface"><a id="close" class="tsd-anchor"></a><h3>close</h3><ul class="tsd-signatures tsd-kind-method tsd-parent-kind-interface"><li class="tsd-signature tsd-kind-icon">close<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">void</span></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/uNetworking/uWebSockets.js/blob/master/docs/index.d.ts#L71">index.d.ts:71</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
|
||||
<p>Forcefully closes this WebSocket. Immediately calls the close handler.
|
||||
No WebSocket close message is sent.</p>
|
||||
</div></div><h4 class="tsd-returns-title">Returns <a href="WebSocket.html" class="tsd-signature-type" data-tsd-kind="Interface">WebSocket</a></h4></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-interface"><a id="cork" class="tsd-anchor"></a><h3>cork</h3><ul class="tsd-signatures tsd-kind-method tsd-parent-kind-interface"><li class="tsd-signature tsd-kind-icon">cork<span class="tsd-signature-symbol">(</span>cb<span class="tsd-signature-symbol">: </span><span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol"> => </span><span class="tsd-signature-type">void</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">void</span></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/uNetworking/uWebSockets.js/blob/master/docs/index.d.ts#L94">index.d.ts:94</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
|
||||
</div></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</span></h4></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-interface"><a id="cork" class="tsd-anchor"></a><h3>cork</h3><ul class="tsd-signatures tsd-kind-method tsd-parent-kind-interface"><li class="tsd-signature tsd-kind-icon">cork<span class="tsd-signature-symbol">(</span>cb<span class="tsd-signature-symbol">: </span><span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol"> => </span><span class="tsd-signature-type">void</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="WebSocket.html" class="tsd-signature-type" data-tsd-kind="Interface">WebSocket</a></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/uNetworking/uWebSockets.js/blob/master/docs/index.d.ts#L94">index.d.ts:94</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
|
||||
<p>See HttpResponse.cork. Takes a function in which the socket is corked (packing many sends into one single syscall/SSL block)</p>
|
||||
</div></div><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5>cb: <span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol"> => </span><span class="tsd-signature-type">void</span></h5><ul class="tsd-parameters"><li class="tsd-parameter-signature"><ul class="tsd-signatures tsd-kind-type-literal"><li class="tsd-signature tsd-kind-icon"><span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">void</span></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</span></h4></li></ul></li></ul></li></ul><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</span></h4></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-interface"><a id="end" class="tsd-anchor"></a><h3>end</h3><ul class="tsd-signatures tsd-kind-method tsd-parent-kind-interface"><li class="tsd-signature tsd-kind-icon">end<span class="tsd-signature-symbol">(</span>code<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">number</span>, shortMessage<span class="tsd-signature-symbol">?: </span><a href="../index.html#RecognizedString" class="tsd-signature-type" data-tsd-kind="Type alias">RecognizedString</a><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="WebSocket.html" class="tsd-signature-type" data-tsd-kind="Interface">WebSocket</a></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/uNetworking/uWebSockets.js/blob/master/docs/index.d.ts#L66">index.d.ts:66</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
|
||||
</div></div><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5>cb: <span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol"> => </span><span class="tsd-signature-type">void</span></h5><ul class="tsd-parameters"><li class="tsd-parameter-signature"><ul class="tsd-signatures tsd-kind-type-literal"><li class="tsd-signature tsd-kind-icon"><span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">void</span></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</span></h4></li></ul></li></ul></li></ul><h4 class="tsd-returns-title">Returns <a href="WebSocket.html" class="tsd-signature-type" data-tsd-kind="Interface">WebSocket</a></h4></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-interface"><a id="end" class="tsd-anchor"></a><h3>end</h3><ul class="tsd-signatures tsd-kind-method tsd-parent-kind-interface"><li class="tsd-signature tsd-kind-icon">end<span class="tsd-signature-symbol">(</span>code<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">number</span>, shortMessage<span class="tsd-signature-symbol">?: </span><a href="../index.html#RecognizedString" class="tsd-signature-type" data-tsd-kind="Type alias">RecognizedString</a><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">void</span></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/uNetworking/uWebSockets.js/blob/master/docs/index.d.ts#L66">index.d.ts:66</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
|
||||
<p>Gracefully closes this WebSocket. Immediately calls the close handler.
|
||||
A WebSocket close message is sent with code and shortMessage.</p>
|
||||
</div></div><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5><span class="tsd-flag ts-flagOptional">Optional</span> code: <span class="tsd-signature-type">number</span></h5></li><li><h5><span class="tsd-flag ts-flagOptional">Optional</span> shortMessage: <a href="../index.html#RecognizedString" class="tsd-signature-type" data-tsd-kind="Type alias">RecognizedString</a></h5></li></ul><h4 class="tsd-returns-title">Returns <a href="WebSocket.html" class="tsd-signature-type" data-tsd-kind="Interface">WebSocket</a></h4></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-interface"><a id="getBufferedAmount" class="tsd-anchor"></a><h3>get<wbr/>Buffered<wbr/>Amount</h3><ul class="tsd-signatures tsd-kind-method tsd-parent-kind-interface"><li class="tsd-signature tsd-kind-icon">get<wbr/>Buffered<wbr/>Amount<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/uNetworking/uWebSockets.js/blob/master/docs/index.d.ts#L61">index.d.ts:61</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
|
||||
</div></div><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5><span class="tsd-flag ts-flagOptional">Optional</span> code: <span class="tsd-signature-type">number</span></h5></li><li><h5><span class="tsd-flag ts-flagOptional">Optional</span> shortMessage: <a href="../index.html#RecognizedString" class="tsd-signature-type" data-tsd-kind="Type alias">RecognizedString</a></h5></li></ul><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</span></h4></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-interface"><a id="getBufferedAmount" class="tsd-anchor"></a><h3>get<wbr/>Buffered<wbr/>Amount</h3><ul class="tsd-signatures tsd-kind-method tsd-parent-kind-interface"><li class="tsd-signature tsd-kind-icon">get<wbr/>Buffered<wbr/>Amount<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/uNetworking/uWebSockets.js/blob/master/docs/index.d.ts#L61">index.d.ts:61</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
|
||||
<p>Returns the bytes buffered in backpressure. This is similar to the bufferedAmount property in the browser counterpart.
|
||||
Check backpressure example.</p>
|
||||
</div></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">number</span></h4></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-interface"><a id="getRemoteAddress" class="tsd-anchor"></a><h3>get<wbr/>Remote<wbr/>Address</h3><ul class="tsd-signatures tsd-kind-method tsd-parent-kind-interface"><li class="tsd-signature tsd-kind-icon">get<wbr/>Remote<wbr/>Address<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">ArrayBuffer</span></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/uNetworking/uWebSockets.js/blob/master/docs/index.d.ts#L103">index.d.ts:103</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
|
||||
|
8
docs/index.d.ts
vendored
8
docs/index.d.ts
vendored
@ -63,12 +63,12 @@ export interface WebSocket {
|
||||
/** Gracefully closes this WebSocket. Immediately calls the close handler.
|
||||
* A WebSocket close message is sent with code and shortMessage.
|
||||
*/
|
||||
end(code?: number, shortMessage?: RecognizedString) : WebSocket;
|
||||
end(code?: number, shortMessage?: RecognizedString) : void;
|
||||
|
||||
/** Forcefully closes this WebSocket. Immediately calls the close handler.
|
||||
* No WebSocket close message is sent.
|
||||
*/
|
||||
close() : WebSocket;
|
||||
close() : void;
|
||||
|
||||
/** Sends a ping control message. Returns true on success in similar ways as WebSocket.send does (regarding backpressure). This helper function correlates to WebSocket::send(message, uWS::OpCode::PING, ...) in C++. */
|
||||
ping(message?: RecognizedString) : boolean;
|
||||
@ -91,7 +91,7 @@ export interface WebSocket {
|
||||
publish(topic: RecognizedString, message: RecognizedString, isBinary?: boolean, compress?: boolean) : boolean;
|
||||
|
||||
/** See HttpResponse.cork. Takes a function in which the socket is corked (packing many sends into one single syscall/SSL block) */
|
||||
cork(cb: () => void) : void;
|
||||
cork(cb: () => void) : WebSocket;
|
||||
|
||||
/** Returns the remote IP address. Note that the returned IP is binary, not text.
|
||||
*
|
||||
@ -183,7 +183,7 @@ export interface HttpResponse {
|
||||
* res.writeStatus("200 OK").writeHeader("Some", "Value").write("Hello world!");
|
||||
* });
|
||||
*/
|
||||
cork(cb: () => void) : void;
|
||||
cork(cb: () => void) : HttpResponse;
|
||||
|
||||
/** Upgrades a HttpResponse to a WebSocket. See UpgradeAsync, UpgradeSync example files. */
|
||||
upgrade<T>(userData : T, secWebSocketKey: RecognizedString, secWebSocketProtocol: RecognizedString, secWebSocketExtensions: RecognizedString, context: us_socket_context_t) : void;
|
||||
|
@ -71,7 +71,7 @@ struct WebSocketWrapper {
|
||||
}
|
||||
}
|
||||
|
||||
/* Takes string topic, message */
|
||||
/* Takes string topic, message, returns boolean success */
|
||||
template <bool SSL>
|
||||
static void uWS_WebSocket_publish(const FunctionCallbackInfo<Value> &args) {
|
||||
Isolate *isolate = args.GetIsolate();
|
||||
@ -90,7 +90,8 @@ struct WebSocketWrapper {
|
||||
return;
|
||||
}
|
||||
|
||||
ws->publish(topic.getString(), message.getString(), args[2]->BooleanValue(isolate) ? uWS::OpCode::BINARY : uWS::OpCode::TEXT, args[3]->BooleanValue(isolate));
|
||||
bool success = ws->publish(topic.getString(), message.getString(), args[2]->BooleanValue(isolate) ? uWS::OpCode::BINARY : uWS::OpCode::TEXT, args[3]->BooleanValue(isolate));
|
||||
args.GetReturnValue().Set(Boolean::New(isolate, success));
|
||||
}
|
||||
}
|
||||
|
||||
@ -315,7 +316,7 @@ struct WebSocketWrapper {
|
||||
wsTemplateLocal->PrototypeTemplate()->Set(String::NewFromUtf8(isolate, "sendFirstFragment", NewStringType::kNormal).ToLocalChecked(), FunctionTemplate::New(isolate, uWS_WebSocket_sendFirstFragment<SSL>));
|
||||
wsTemplateLocal->PrototypeTemplate()->Set(String::NewFromUtf8(isolate, "sendFragment", NewStringType::kNormal).ToLocalChecked(), FunctionTemplate::New(isolate, uWS_WebSocket_sendFragment<SSL>));
|
||||
wsTemplateLocal->PrototypeTemplate()->Set(String::NewFromUtf8(isolate, "sendLastFragment", NewStringType::kNormal).ToLocalChecked(), FunctionTemplate::New(isolate, uWS_WebSocket_sendLastFragment<SSL>));
|
||||
|
||||
|
||||
wsTemplateLocal->PrototypeTemplate()->Set(String::NewFromUtf8(isolate, "send", NewStringType::kNormal).ToLocalChecked(), FunctionTemplate::New(isolate, uWS_WebSocket_send<SSL>));
|
||||
wsTemplateLocal->PrototypeTemplate()->Set(String::NewFromUtf8(isolate, "end", NewStringType::kNormal).ToLocalChecked(), FunctionTemplate::New(isolate, uWS_WebSocket_end<SSL>));
|
||||
wsTemplateLocal->PrototypeTemplate()->Set(String::NewFromUtf8(isolate, "close", NewStringType::kNormal).ToLocalChecked(), FunctionTemplate::New(isolate, uWS_WebSocket_close<SSL>));
|
||||
|
Loading…
Reference in New Issue
Block a user