Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Jabis Sev贸n
/
gun-multiserver
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
fb15a17b
authored
2020-04-15 23:15:13 +0000
by
Glitch (hello-express)
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Checkpoint
./server.js:13690106/175
1 parent
aa69de6c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
8 deletions
radata/!
server.js
radata/!
View file @
fb15a17
{"jack\u001bname":{"":{":":"Jack",">":1586991774902}}}
\ No newline at end of file
{"jack\u001bname":{"":{":":"Jack",">":1586991984290}}}
\ No newline at end of file
...
...
server.js
View file @
fb15a17
...
...
@@ -13,7 +13,7 @@ const lru = new QuickLRU({maxSize: 1});
server
.
on
(
'upgrade'
,
async
function
(
request
,
socket
,
head
)
{
var
pathname
=
url
.
parse
(
request
.
url
).
pathname
||
'/gun'
;
console
.
log
(
'Got WS request'
,
pathname
);
var
gun
=
false
;
var
gun
=
{
gun
:
false
,
server
:
false
}
;
if
(
pathname
){
if
(
lru
.
has
(
pathname
)){
// Existing Node
...
...
@@ -23,17 +23,17 @@ server.on('upgrade', async function (request, socket, head) {
// Create Node
console
.
log
(
'Create id'
,
pathname
);
var
wserver
=
new
WebSocket
.
Server
({
noServer
:
true
});
gun
=
new
Gun
({
peers
:[],
ws
:
{
path
:
pathname
},
web
:
server
});
lru
.
set
(
pathname
,
gun
);
gun
=
new
Gun
({
peers
:[],
ws
:
{
path
:
pathname
},
web
:
w
server
});
lru
.
set
(
pathname
,
{
gun
:
gun
,
server
:
wserver
}
);
}
}
if
(
gun
){
if
(
gun
.
server
){
// Handle Request
console
.
log
(
'handle connection...'
);
console
.
log
(
'handle connection...'
,
gun
);
//ws.emit('connection', socket);
w
server
.
handleUpgrade
(
request
,
socket
,
head
,
function
(
ws
)
{
gun
.
server
.
handleUpgrade
(
request
,
socket
,
head
,
function
(
ws
)
{
console
.
log
(
'connecting.. '
)
ws
.
emit
(
'connection'
,
socket
);
ws
.
emit
(
'connection'
,
ws
);
});
}
else
{
...
...
Write
Preview
Styling with
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment