This commit is contained in:
Relism
2025-02-28 16:24:15 +00:00
parent 71993af208
commit b73241cb2b
22 changed files with 440 additions and 24 deletions
+1 -1
View File
@@ -58,7 +58,7 @@
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> server.</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">start</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">();</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> }</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">}</span></span></code></pre></div><h2 id="interacting-with-websockets-sessions" tabindex="-1">Interacting with Websockets sessions <a class="header-anchor" href="#interacting-with-websockets-sessions" aria-label="Permalink to &quot;Interacting with Websockets sessions&quot;"></a></h2><p>The <code>WebSocketSession</code> object provides methods to interact with the Websocket session, such as sending messages, closing the connection, and getting the remote address and session ID.</p><table tabindex="0"><thead><tr><th>Method</th><th>Params</th><th>Description</th></tr></thead><tbody><tr><td><code>getChannel()</code></td><td><code>none</code></td><td>Returns an instance of <code>AsynchronousSocketChannel</code> useful for retrieving info about the client .</td></tr><tr><td><code>getRequestInfo()</code></td><td><code>none</code></td><td>Returns an instance of <code>RequestInfo</code> containing all sorts of information about the request (headers, method, path etc.) .</td></tr><tr><td><code>getPath()</code></td><td><code>none</code></td><td>Returns the path to the websocket endpoint as a <code>String</code>.</td></tr><tr><td><code>getId()</code></td><td><code>none</code></td><td>Returns the id of the websocket session as a <code>String</code>, useful if you want to keep track of the connected clients in a custom manager.</td></tr><tr><td><code>getBuffer()</code></td><td><code>none</code></td><td>Returns the ByteBuffer for that session.</td></tr><tr><td><code>sendMessage()</code></td><td><code>String message</code></td><td>Sends the <code>message</code> to the client as a <code>String</code>. it&#39;s up to the developer to stringify and de-stringify any data you want to send back and forth</td></tr><tr><td><code>close()</code></td><td><code>none</code></td><td>Closes the websocket session.</td></tr></tbody></table><div class="warning custom-block"><p class="custom-block-title">NOTE</p><p><code>WebsocketHandler</code> includes a <code>setId(String id)</code> method for overriding the default session ID. Unless you have a specific reason to change it, it&#39;s best to leave it as is.</p><p>Similarly, the <code>setBuffer(ByteBuffer buffer)</code> method allows you to override the default buffer. If you&#39;re unsure about this, it&#39;s recommended to keep the default setting.</p></div></div></div></main><footer class="VPDocFooter" data-v-e6f2a212 data-v-1bcd8184><!--[--><!--]--><!----><nav class="prev-next" aria-labelledby="doc-footer-aria-label" data-v-1bcd8184><span class="visually-hidden" id="doc-footer-aria-label" data-v-1bcd8184>Pager</span><div class="pager" data-v-1bcd8184><a class="VPLink link pager-link prev" href="/flash/core-concepts/server-router.html" data-v-1bcd8184><!--[--><span class="desc" data-v-1bcd8184>Previous page</span><span class="title" data-v-1bcd8184>Server Router</span><!--]--></a></div><div class="pager" data-v-1bcd8184><a class="VPLink link pager-link next" href="/flash/file-serving/static-file-server.html" data-v-1bcd8184><!--[--><span class="desc" data-v-1bcd8184>Next page</span><span class="title" data-v-1bcd8184>Static Files Server</span><!--]--></a></div></nav></footer><!--[--><!--]--></div></div></div><!--[--><!--]--></div></div><!----><!--[--><!--]--></div></div>
<script>window.__VP_HASH_MAP__=JSON.parse("{\"flash_advanced_fullstack-development.md\":\"DFJ2Nfm_\",\"flash_advanced_handler-default-implementations.md\":\"Bai_t_s4\",\"flash_core-concepts_handlers.md\":\"B1156l1I\",\"flash_core-concepts_request-handler.md\":\"fjZWLpOw\",\"flash_core-concepts_request-response.md\":\"3C-3EYgj\",\"flash_core-concepts_server-router.md\":\"BtmNSZRo\",\"flash_core-concepts_websockets.md\":\"ByGVX96c\",\"flash_file-serving_dynamic-file-server.md\":\"DY_r4ecH\",\"flash_file-serving_static-file-server.md\":\"BvN0FZB2\",\"flash_index.md\":\"E5zPbZtg\",\"flash_introduction_installation.md\":\"BEOKwAAp\",\"index.md\":\"CgmTRI0Q\",\"mobot_index.md\":\"Be0Zoetq\",\"serverlibraries_index.md\":\"CeIqSPIs\"}");window.__VP_SITE_DATA__=JSON.parse("{\"lang\":\"en-US\",\"dir\":\"ltr\",\"title\":\"Pixel Services Docs\",\"description\":\"Documentation for all public Pixel Services projects.\",\"base\":\"/\",\"head\":[],\"router\":{\"prefetchLinks\":true},\"appearance\":true,\"themeConfig\":{\"logo\":\"https://static.pixel-services.com/static/assets/pservices_logo.png\",\"sidebar\":{\"/flash/\":[{\"text\":\"Introduction\",\"collapsed\":false,\"items\":[{\"text\":\"Getting Started\",\"link\":\"/flash\"},{\"text\":\"Installation\",\"link\":\"/flash/introduction/installation\"}]},{\"text\":\"Core Concepts\",\"collapsed\":false,\"items\":[{\"text\":\"Handlers\",\"link\":\"/flash/core-concepts/handlers\"},{\"text\":\"RequestHandler\",\"link\":\"/flash/core-concepts/request-handler\"},{\"text\":\"Request and Response\",\"link\":\"/flash/core-concepts/request-response\"},{\"text\":\"Server Router\",\"link\":\"/flash/core-concepts/server-router\"},{\"text\":\"Websockets\",\"link\":\"/flash/core-concepts/websockets\"}]},{\"text\":\"File Serving\",\"collapsed\":false,\"items\":[{\"text\":\"Static Files Server\",\"link\":\"/flash/file-serving/static-file-server\"},{\"text\":\"Dynamic Files Server\",\"link\":\"/flash/file-serving/dynamic-file-server\"}]},{\"text\":\"Advanced\",\"collapsed\":false,\"items\":[{\"text\":\"Handler Default Implementations\",\"link\":\"/flash/advanced/handler-default-implementations\"},{\"text\":\"Fullstack Development\",\"link\":\"/flash/advanced/fullstack-development\"}]}],\"/mobot/\":[{\"text\":\"MoBot Documentation\",\"items\":[{\"text\":\"Getting Started\",\"link\":\"/mobot\"}]}],\"/serverlibraries/\":[{\"text\":\"ServerLibraries Documentation\",\"items\":[{\"text\":\"Getting Started\",\"link\":\"/serverlibraries\"}]}]}},\"locales\":{},\"scrollOffset\":134,\"cleanUrls\":false}");</script>
<script>window.__VP_HASH_MAP__=JSON.parse("{\"flash_advanced_fullstack-development.md\":\"DFJ2Nfm_\",\"flash_advanced_handler-default-implementations.md\":\"ki9D2CCK\",\"flash_core-concepts_handlers.md\":\"B1156l1I\",\"flash_core-concepts_request-handler.md\":\"fjZWLpOw\",\"flash_core-concepts_request-response.md\":\"BuTSfkDO\",\"flash_core-concepts_server-router.md\":\"Dpvzqe12\",\"flash_core-concepts_websockets.md\":\"ByGVX96c\",\"flash_file-serving_dynamic-file-server.md\":\"DY_r4ecH\",\"flash_file-serving_static-file-server.md\":\"BvN0FZB2\",\"flash_index.md\":\"E5zPbZtg\",\"flash_introduction_installation.md\":\"BEOKwAAp\",\"index.md\":\"CgmTRI0Q\",\"mobot_index.md\":\"Be0Zoetq\",\"serverlibraries_index.md\":\"CeIqSPIs\"}");window.__VP_SITE_DATA__=JSON.parse("{\"lang\":\"en-US\",\"dir\":\"ltr\",\"title\":\"Pixel Services Docs\",\"description\":\"Documentation for all public Pixel Services projects.\",\"base\":\"/\",\"head\":[],\"router\":{\"prefetchLinks\":true},\"appearance\":true,\"themeConfig\":{\"logo\":\"https://static.pixel-services.com/static/assets/pservices_logo.png\",\"sidebar\":{\"/flash/\":[{\"text\":\"Introduction\",\"collapsed\":false,\"items\":[{\"text\":\"Getting Started\",\"link\":\"/flash\"},{\"text\":\"Installation\",\"link\":\"/flash/introduction/installation\"}]},{\"text\":\"Core Concepts\",\"collapsed\":false,\"items\":[{\"text\":\"Handlers\",\"link\":\"/flash/core-concepts/handlers\"},{\"text\":\"RequestHandler\",\"link\":\"/flash/core-concepts/request-handler\"},{\"text\":\"Request and Response\",\"link\":\"/flash/core-concepts/request-response\"},{\"text\":\"Server Router\",\"link\":\"/flash/core-concepts/server-router\"},{\"text\":\"Websockets\",\"link\":\"/flash/core-concepts/websockets\"}]},{\"text\":\"File Serving\",\"collapsed\":false,\"items\":[{\"text\":\"Static Files Server\",\"link\":\"/flash/file-serving/static-file-server\"},{\"text\":\"Dynamic Files Server\",\"link\":\"/flash/file-serving/dynamic-file-server\"}]},{\"text\":\"Advanced\",\"collapsed\":false,\"items\":[{\"text\":\"Handler Default Implementations\",\"link\":\"/flash/advanced/handler-default-implementations\"},{\"text\":\"Fullstack Development\",\"link\":\"/flash/advanced/fullstack-development\"}]}],\"/mobot/\":[{\"text\":\"MoBot Documentation\",\"items\":[{\"text\":\"Getting Started\",\"link\":\"/mobot\"}]}],\"/serverlibraries/\":[{\"text\":\"ServerLibraries Documentation\",\"items\":[{\"text\":\"Getting Started\",\"link\":\"/serverlibraries\"}]}]}},\"locales\":{},\"scrollOffset\":134,\"cleanUrls\":false}");</script>
</body>
</html>