Hello everyone,
I’m trying to publish a file in one terminal and I want other terminals can get the file.
I use this example here
In this example nodes are created in a single js file but I need to call them from different terminals.
async function createNode() {
const node = await Libp2p.create({
addresses: {
listen: ['/ip4/0.0.0.0/tcp/0']
},
modules: {
transport: [ TCP ],
streamMuxer: [ Mplex ],
connEncryption: [ NOISE ],
pubsub: Gossipsub
}
await node.start()
return node
})
const topic = 'news'
const node =await createNode();
node.pubsub.on(topic, (msg) => {
console.log(`node received: ${toString(msg.data)}`)
})
await node.pubsub.subscribe(topic)
setInterval(() => {
node.pubsub.publish(topic, fromString('Bird bird bird, bird is the word!'))
}, 1000)
I call this js file with command ‘node peer.js’ in two different terminals but Nodes cannot see each other.
How can I make it that I subscribe and publish a file between two terminals?