armeria
armeria copied to clipboard
Add WebSocketService
Motivation: It would be nice if we can provide a service that supports The WebSocket Protocol
Modifications:
- Add
WebSocketService
andWebSocketHandler
to implement the service using back pressure. - Add
WebSocketFrame
that represents the web socket frames. - Add the interface
BinaryData
and its implementation:-
ByteBufBinaryData
andByteArrayBinaryData
which, previously, wereByteArrayHttpData
andByteBufHttpData
. -
WebSocketFrame
also usesBinaryData
to store the application data.
-
Result:
- You can now use
WebSocketService
to send WebSocket messages.ServerBuilder sb = ... WebSocketHandler backpressureHandler = (ctx, messages) -> { WebSocketWriter webSocketWriter = WebSocket.streaming(); // Write frames using back pressure. return webSocketWriter; }; sb.service("/chat", WebSocketService.of(backpressureHandler));
Todos:
- Provide another abstract class for the
WebSocketHandler
so that a user can implement WebSocket easily without considering back pressure. (next PR) - Support WebSocketClient. (next PR)
- Support extensions. (next PR)
Codecov Report
:exclamation: No coverage uploaded for pull request base (
main@62349ab
). Click here to learn what that means. Patch has no changes to coverable lines.
:exclamation: Current head d35ec9a differs from pull request most recent head e518594. Consider uploading reports for the commit e518594 to get more accurate results
Additional details and impacted files
@@ Coverage Diff @@
## main #3904 +/- ##
=======================================
Coverage ? 73.28%
Complexity ? 15860
=======================================
Files ? 1394
Lines ? 60933
Branches ? 7771
=======================================
Hits ? 44653
Misses ? 12355
Partials ? 3925
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.
I think this is ready for review. 😉
@ikhoon All fixed. PTAL. 😉
I think this is ready. 😄 PTAL. 🙇
All addressed. PTAL. 🙇
Thanks a lot for reviewing. 🙇♂️