You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Feb 10, 2019. It is now read-only.
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?
The text was updated successfully, but these errors were encountered:
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 freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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:
This is where we have no idea what to so. Now how does one send messages? We can see something like:
Being used to send a "node::test" event to everyone on the network. That is then received with:
But that doesn't work... Any idea?
The text was updated successfully, but these errors were encountered: