-
Hey guys! I am following the chat example and I am building a p2p node type of personal project which sends and received messages from multiple nodes/peers. I kind of wanted a functionality to send a message to a node with particular peer_id which we get when we receive the message shown here. Is there way I can do this? Or any workaround I can use. Really appreciate your help. Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Your solution would likely be to use |
Beta Was this translation helpful? Give feedback.
-
Hey @dariusc93! Thanks for the above suggestions! I need just one more help is how do I make the chat example connect on different devices with different IP addresses. Right now it can connect two ports on the same device but what modifications shall I do in order to make it multi IP address supported. |
Beta Was this translation helpful? Give feedback.
Your solution would likely be to use
libp2p-request-response
orlibp2p-stream
for ease of use if youre sending a single message to a specific peer, however you could also use oneshot in your own behaviour or write your own protocol for this. Now if you really want to use gossipsub (for floodsub), you could have each peer have their own dedicated topic that they are subscribed too and publish messages to that specific topic when you are connected to that peer (or to a peer that is subscribed to that topic), or encrypt the message for the intended peer and broadcast it on a common topic that they all would be subscribed too and attempt to decrypt that message (this will require you to figur…