[feat] provide SSE (ServerSentEvents) as alternative to websocket #14552
Replies: 7 comments
-
|
here is js code: stream.ts |
Beta Was this translation helpful? Give feedback.
-
|
I'm pretty new to Tauri so maybe I'm missing something but I was able to connect to a server emitting SSE with this JS in my frontend The server was either running on the side manually or embedding with the app as a sidecar. Maybe it would not work if the SSE were emitted directly by the Rust Tauri backend? |
Beta Was this translation helpful? Give feedback.
-
|
My understanding of the OP is that they want to send SSE from the tauri rust backend. The frontend being a webview, it makes sense that they can get data from the stream since it is more or less just a fancy get request from the front end's point of view. |
Beta Was this translation helpful? Give feedback.
-
|
I'm starting to write a plugin for SSE. I'm working on it slowly. If someone wants to contribute, do feel free. The generic idea is to tell Rust to send request to wait for server event. |
Beta Was this translation helpful? Give feedback.
-
|
@amitnos123 Would your approach work with systems that already use SSE, for example Datastar? |
Beta Was this translation helpful? Give feedback.
-
|
@AndrooFrowns I'm making a wrapper for crate sse_client The Rust (Tauri's backend) will trigger event to tell the Tauri's frontend the SSE occoured. Server -> Rust (Tauri's backend) -> Tauri's frontend
|
Beta Was this translation helpful? Give feedback.
-
|
@AndrooFrowns Wanted to tell you |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Describe the problem
Currently we need to use
@tauriApps/plugin-websocketfor unidirectional streaming (from server to client). However, there is another web standard specifically for such unidirectional streaming: Server Sent Events (SSE).Describe the solution you'd like
Would be nice to also have
@tauriApps/plugin-sseto support "server sent events".Especially for mobile applications, SSE is a much more energy-saving alternative. Btw, in contrast to the use of the "web's native implementation", Tauri can even improve SSE communication by
Alternatives considered
No response
Additional context
No response
Beta Was this translation helpful? Give feedback.
All reactions