Skip to content
This repository has been archived by the owner on Feb 10, 2019. It is now read-only.

Unable to send messages through the network #1

Open
breadbored opened this issue Feb 15, 2015 · 1 comment
Open

Unable to send messages through the network #1

breadbored opened this issue Feb 15, 2015 · 1 comment

Comments

@breadbored
Copy link

We are able to make a connection to the network, show when people connect, disconnect, and who all is online.

Here is what we have to show for it:

var Node = require('n2n').Node;
var node = new Node(5146);

console.log("Connecting to the network...\n\n\n");
node.connect([{ host: 'bradleypl.us', port: 5146 }]);

node.on('online', function () {
  console.log('Your ID:', this.id);
  console.log('Online ids:', node.sortedIds);
});

//just for testing, this will spam the terminal if repeated every time.
node.on('node::online', function (newNode) {
  console.log('Someone is online:', newNode.id);
});

//just for testing, this will spam the terminal if repeated every time.
node.on('node::offline', function () {
  console.log('Someone just left!');
});

This is where we have no idea what to so. Now how does one send messages? We can see something like:

node.broadcast("node::test","message");

Being used to send a "node::test" event to everyone on the network. That is then received with:

node.on("node::test", function (message) {
  console.log("New message:",message);
}

But that doesn't work... Any idea?

@vroomDotClub
Copy link

Try node.broadcast("test","message");
and on the receive event fnct
node.on("node::test", function (senderID,message) {
console.log("New message:",message);
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants