Skip to content
This repository was archived by the owner on Jan 31, 2026. It is now read-only.

Add Websocket support#96

Closed
FrankenApps wants to merge 4 commits intoTienisto:mainfrom
FrankenApps:websocket
Closed

Add Websocket support#96
FrankenApps wants to merge 4 commits intoTienisto:mainfrom
FrankenApps:websocket

Conversation

@FrankenApps
Copy link
Contributor

@FrankenApps FrankenApps commented Jan 5, 2026

This adds rudimentary WebSocket support using reqwest-websocket.

This was requested in #72.

A few things are still missing:

  • Proper error handling
  • Higher Level API that wraps the auto-generated types provided by flutter_rust_bridge
  • Better support for binary messages
  • Testing
  • Documentation

I am just opening this in order to hopefully gather some early feedback on the general API and whether the current approach seems to be fine overall.

The size increase of a "fat" APK seems to be around 0.5 MB (56.9 MB without WS and 57.4 MB with).

websocket

import 'package:rhttp/src/rust/api/http.dart' show HttpMethod;
import 'package:rhttp/src/rust/api/websocket.dart' as rust;

class RhttpWebsocketClient {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be RhttpWebsocketConnection because it represents one single connection and cannot be reused.

class RhttpWebsocketClient {
rust.WebSocketHandle _handle;

Stream<rust.RhttpWebSocketEvent> stream;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe a private StreamController + exposing a Stream get => _streamController.stream would offer more flexibility.
But this is just implementation. The current API is fine.

@Tienisto
Copy link
Owner

Tienisto commented Jan 7, 2026

I believe the stream should be a union type of String + Uint8List. A sealed class might fit here.

@Tienisto
Copy link
Owner

Development moved to Codeberg: https://codeberg.org/Tienisto/rhttp

@Tienisto Tienisto closed this Jan 31, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants