Single HTTP/S
server providing multiple ephemeral GunDB WebSocket
instances with path based routing and mesh isolation.
- uses its own mem storage adaptor to avoid any disk writes
- uses its own websockets adaptor allowing injection into Gun contructors
- MUST be served through SSL and can easily be deployed on glitch and other platforms.
- requires a valid set of SSL/TLS certificates (letsencrypt)
npm install
Explode your ENV variables manually and launch using npm:
SSL=true SSLKEY=/path/to/privkey.pem SSLCERT=/path/to/fullchain.pem npm start
Configure the options in multisocket.config.js
and launch using pm2:
pm2 start multisocket.config.js
In this example we want the data of Jack and Jill to be partitioned and not shared between different ws /paths
localStorage.clear();
// Create the first gun endpoint
var random1 = Math.random().toString(36).substring(7);
var gun1 = Gun({peers:["https://gundb-multiserver.glitch.me/"+random1], musticast: false, localStorage: false, radisk: false, file: false});
// Create Jack
gun1.get('jack').put({ name: "Jack" });
// This should be triggered for Jack only
gun1.get('jack').on(function(data, key){
console.log("gun 1 update:", data);
});
// This should never be triggered! It's from Jill after all.
gun1.get('jill').on(function(data, key){
console.log("Jack should NOT see Jill's update", data);
});
// Create the second gun endpoint
var random2 = Math.random().toString(36).substring(7);
var gun2 = Gun({peers:["https://gundb-multiserver.glitch.me/"+random2], multicast: false, localStorage: false, radisk: false, file: false});
// Create Jill
gun2.get('jill').put({ name: "Jill"});
// This should be triggered for Jill only
gun2.get('jill').on(function(data, key){
console.log("gun 2 update:", data);
});
This project is a component of Gun Meething powered by GunDB