How to subscribe events onClose, onConnect, onError in websocket ?
See original GitHub issueI can only subscribe to the message event
webSocket("api") {
incoming.consumeEach { frame ->
when (frame) {
is Frame.Close -> println("close") // not work
is Frame.Binary -> {
val length = frame.buffer.remaining()
val byteArray = ByteArray(length)
frame.buffer.get(byteArray)
val request = Mapper.mapTo<Request<Any>>(byteArray)
}
}
}
}
Such an opportunity will be in the future?
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:5 (2 by maintainers)
Top Results From Across the Web
How to get access to onclose event codes in Javascript ...
Try this: function onClose(event) { alert('Onclose called' + event); alert('code is' + event.code); alert('reason is ' + event.reason); alert('wasClean is' ...
Read more >WebSockets - Events & Actions - Tutorialspoint
Close event marks the end of the communication between server and the client. Closing the connection is possible with the help of onclose...
Read more >WebSocket - The Modern JavaScript Tutorial
There are totally 4 events: open – connection established,; message – data received,; error – websocket error,; close – connection closed.
Read more >WebSocket: close event - Web APIs - MDN Web Docs
The close event is fired when a connection with a WebSocket is closed. Syntax. Use the event name in methods like addEventListener() ,...
Read more >Using WebSockets - Quarkus
Because it's the canonical web socket application, we are going to create a simple chat ... session); } @OnClose public void onClose(Session session, ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
incoming
channel simply gets closed, a close reason could be obtained fromcloseReason
deferredincoming
channel gets closed with error (attempt to receive on this channel will cause it to throw an exception) and/orcloseReason
could be completed with the reason@soywiz Since this approach looks different too the classic approach we probably can add a small notice at our page http://ktor.io/servers/features/websockets.html