How to implement a protocol

Hi, I’m using js-libp2p and trying to implement a custom protocol.

I want a node to dial another and they should start exchanging messages back and forth, but I just can’t make that work.

I’m having trouble implementing the code to send a message from one node while the other waits for it then the receiver needs to do something async and come back with the answer later while the first one waits for the answer. That process needs to keep going until one of them decides it’s done.

I tried several combinations of it-pipe, it-last, it-pushable to implement this “conversation”, but I couldn’t make it work.

Can anyone help me with that?

Do you have code pushed up anywhere? What part of it isn’t working? Are you able to send any messages?