A Collaborative text editor

I want to use ICED and build a collaborative text editor. For that functionality to work currently I am only working with establishing the Communication with Local host via websocket with another text editor. But currently I am having hardtime Understanding how to integrate websockets. I have used websockets demo in ICED examples, But I dont Understand why the messages in the example are not broadcasted over in the websocket port ?. I was monitoring the websocket port using the wscat tool but I cant see any messages that I type in the demo window. Maybe I misunderstood How it works ?. Currently I am trying to understand how to work with subscriptions since that way I can tell my broadcast channel what I am typing in ICED. my way over Understanding is that the subscription handovers some channel then how to get hold of that channel to broadcast the text editor content ?

I am not sure what exactly is your issue. If you are unsure how subscriptions and tasks work, you might want to read Runtime - Unofficial Iced Guide.

There are two ways to get updates into a task/subscription. One would be two have a channel that is read from the task/subscription. The other would be to use a std::sync::Arc<tokio::sync::Mutex<T>> and cloning it into the subscription.

I want to send the input events from the keyboard to the websocket whenever i get events from keyboard to the tex_editor widget. what will be the best way to do that ?

Whenever you receive an Action in your on_edit message, you send it through something like an mpsc

But the mpsc is wrapped in another message which i get through subscription then should i store the Action in some intermediate value or may be a vec and send it like that ? then there will be a delay. how to instantly send the action ?

You receive an mpsc Sender from the subscription that you then store in your state.

Then in my state i refer to my stored sender and called it repeatedly in update method ? to send the data from channel to the subscription back to broadcast it through websocket ?


I am getting this error If I do so