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
18936c38
authored
2020-04-15 23:38:12 +0000
by
Glitch (hello-express)
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Checkpoint
./server.js:13690106/69
1 parent
6e7b43f0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
4 deletions
server.js
server.js
View file @
18936c3
...
...
@@ -2,7 +2,7 @@ const url = require('url');
const
Gun
=
require
(
'gun'
);
const
http
=
require
(
'http'
);
const
WebSocket
=
require
(
'ws'
);
var
server
=
http
.
createServer
()
.
listen
(
3000
)
;
var
server
=
http
.
createServer
();
// LRU with last used sockets
const
QuickLRU
=
require
(
'quick-lru'
);
...
...
@@ -23,7 +23,7 @@ server.on('upgrade', async function (request, socket, head) {
// Create Node
console
.
log
(
'Create id'
,
pathname
);
gun
.
server
=
new
WebSocket
.
Server
({
noServer
:
true
});
gun
.
gun
=
new
Gun
({
peers
:[],
ws
:
{
noServer
:
true
,
path
:
pathname
}
});
gun
.
gun
=
new
Gun
({
peers
:[],
ws
:
{
noServer
:
true
}
});
lru
.
set
(
pathname
,
gun
);
}
}
...
...
@@ -33,10 +33,13 @@ server.on('upgrade', async function (request, socket, head) {
//ws.emit('connection', socket);
gun
.
server
.
handleUpgrade
(
request
,
socket
,
head
,
function
(
ws
)
{
console
.
log
(
'connecting.. '
)
ws
.
emit
(
'connection'
,
ws
);
gun
.
server
.
emit
(
'connection'
,
ws
);
});
}
else
{
socket
.
destroy
();
}
});
\ No newline at end of file
});
server
.
listen
(
3000
);
\ No newline at end of file
...
...
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