swarm with web-socket #4305
-
I want to use Websocket in my libp2p project. when a ws client sends a message to the server. the server will send that message via libp2p. so I have initialized the web socket in my project. when I connect a ws client with the ws server the server is listening to everything about the client. The socket working perfectly for now. then when a message is received from a ws client, the ws server is sending that via libp2p. and publish method is returning Ok(). but the message does not arrive where I sent it via libp2p. Send Method :
then when I disconnect the ws from the client. then the message arrives at to libp2p receiver. that mean libp2p not sending messages. but publish method returned Ok(). I used a loop ( pin_mut) to listen to the WS events in tokio::select{}. where libp2p also listening events.
and I can't listen to the ws events in another thread because I have to transfer a reference of the swarm to publish a message. no progress in my work for a few days. please help me. thanks. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 6 replies
-
Your problem might be that |
Beta Was this translation helpful? Give feedback.
The file-sharing example uses a channel to send commands to an event-loop that polls the swarm: https://github.com/libp2p/rust-libp2p/tree/master/examples/file-sharing
Hope that helps :)