3670d70b by Lorenzo Mangani

resync

1 parent 971901b5
...@@ -8,11 +8,24 @@ Single `HTTP/S` server providing `WebSocket` Path based routing to ephemeral [Gu ...@@ -8,11 +8,24 @@ Single `HTTP/S` server providing `WebSocket` Path based routing to ephemeral [Gu
8 * uses its own [websockets](https://github.com/meething/gundb-multisocket/blob/master/gun-ws.js) adaptor allowing injection into Gun contructors 8 * uses its own [websockets](https://github.com/meething/gundb-multisocket/blob/master/gun-ws.js) adaptor allowing injection into Gun contructors
9 * MUST be served through SSL and can easily be deployed on [glitch](https://glitch.com/~gundb-multiserver) and other platforms. 9 * MUST be served through SSL and can easily be deployed on [glitch](https://glitch.com/~gundb-multiserver) and other platforms.
10 10
11 ### Configuration
12 * requires a valid set of SSL/TLS certificates _(letsencrypt)_
11 13
12 ### Installation 14 ### Installation
13 ``` 15 ```
14 npm install 16 npm install
15 npm start 17 ```
18
19 ### Usage
20 #### npm
21 Explode your ENV variables manually and launch using npm:
22 ```
23 SSL=true SSLKEY=/path/to/privkey.pem SSLCERT=/path/to/fullchain.pem npm start
24 ```
25 #### pm2
26 Configure the options in `multisocket.config.js` and launch using pm2:
27 ```
28 pm2 start multisocket.config.js
16 ``` 29 ```
17 30
18 [![Remix on Glitch](https://cdn.glitch.com/2703baf2-b643-4da7-ab91-7ee2a2d00b5b%2Fremix-button.svg)](https://glitch.com/edit/#!/import/github/https://github.com/meething/gundb-multisocket/gundb-multisocket) 31 [![Remix on Glitch](https://cdn.glitch.com/2703baf2-b643-4da7-ab91-7ee2a2d00b5b%2Fremix-button.svg)](https://glitch.com/edit/#!/import/github/https://github.com/meething/gundb-multisocket/gundb-multisocket)
...@@ -21,25 +34,32 @@ npm start ...@@ -21,25 +34,32 @@ npm start
21 34
22 <img src="https://user-images.githubusercontent.com/1423657/79556065-d4b55e00-80a0-11ea-8a6a-b85aa0c90cf0.png" width=500/> 35 <img src="https://user-images.githubusercontent.com/1423657/79556065-d4b55e00-80a0-11ea-8a6a-b85aa0c90cf0.png" width=500/>
23 36
24 #### Example 37 #### Practical Example
38 In this example we want the data of Jack and Jill to be partitioned and not shared between different ws /paths
25 ``` 39 ```
26 localStorage.clear(); 40 localStorage.clear();
27 41
42 // Create the first gun endpoint
28 var random1 = Math.random().toString(36).substring(7); 43 var random1 = Math.random().toString(36).substring(7);
29 var gun1 = Gun({peers:["https://gundb-multiserver.glitch.me/"+random1], musticast: false, localStorage: false, radisk: false, file: false}); 44 var gun1 = Gun({peers:["https://gundb-multiserver.glitch.me/"+random1], musticast: false, localStorage: false, radisk: false, file: false});
45 // Create Jack
30 gun1.get('jack').put({ name: "Jack" }); 46 gun1.get('jack').put({ name: "Jack" });
31 // This should be triggered 47
48 // This should be triggered for Jack only
32 gun1.get('jack').on(function(data, key){ 49 gun1.get('jack').on(function(data, key){
33 console.log("gun 1 update:", data); 50 console.log("gun 1 update:", data);
34 }); 51 });
35 // This should never be triggered 52 // This should never be triggered! It's from Jill after all.
36 gun1.get('jill').on(function(data, key){ 53 gun1.get('jill').on(function(data, key){
37 console.log("Jack should NOT see Jill's update", data); 54 console.log("Jack should NOT see Jill's update", data);
38 }); 55 });
39 56
57 // Create the second gun endpoint
40 var random2 = Math.random().toString(36).substring(7); 58 var random2 = Math.random().toString(36).substring(7);
41 var gun2 = Gun({peers:["https://gundb-multiserver.glitch.me/"+random2], multicast: false, localStorage: false, radisk: false, file: false}); 59 var gun2 = Gun({peers:["https://gundb-multiserver.glitch.me/"+random2], multicast: false, localStorage: false, radisk: false, file: false});
60 // Create Jill
42 gun2.get('jill').put({ name: "Jill"}); 61 gun2.get('jill').put({ name: "Jill"});
62 // This should be triggered for Jill only
43 gun2.get('jill').on(function(data, key){ 63 gun2.get('jill').on(function(data, key){
44 console.log("gun 2 update:", data); 64 console.log("gun 2 update:", data);
45 }); 65 });
......
1 module.exports = {
2 apps : [{
3 name: 'multisocket",
4 script: 'server.js',
5 watch: true
6 env: {
7 SSL : false,
8 SSLKEY : 'cert/server.key',
9 SSLCERT : 'cert/server.cert',
10 DEBUG : false
11 }
12 }]
13 };
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!