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
6a1b588e
authored
2020-05-03 15:23:19 +0200
by
Jabis Sevón
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
let's not put undefineds in
1 parent
34c50db8
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
6 deletions
multisocket.config.js
server.js
multisocket.config.js
View file @
6a1b588
...
...
@@ -2,7 +2,7 @@ module.exports = {
apps
:
[{
name
:
'multisocket'
,
script
:
'server.js'
,
watch
:
tru
e
,
watch
:
fals
e
,
env
:
{
DEBUG
:
true
}
...
...
server.js
View file @
6a1b588
...
...
@@ -16,9 +16,9 @@ const http = require("http");
const
https
=
require
(
"https"
);
const
WebSocket
=
require
(
"ws"
);
let
debug
=
process
.
env
.
DEBUG
||
true
;
let
relaypeers
=
process
.
env
.
RELAY
||
'https://m
g
.rig.airfaas.com/'
;
let
relaypeers
=
process
.
env
.
RELAY
||
'https://m
irror
.rig.airfaas.com/'
;
let
config
=
{};
if
(
debug
)
console
.
log
(
SEA
,
Gun
.
SEA
);
if
(
debug
)
console
.
log
(
SEA
);
config
.
options
=
{
}
if
(
!
process
.
env
.
hasOwnProperty
(
'SSL'
)
||
process
.
env
.
SSL
==
false
)
{
...
...
@@ -98,10 +98,10 @@ server.on("upgrade", async function(request, socket, head) {
let
user
=
g
.
user
();
user
.
create
(
roomname
,
sig
,
function
(
dack
){
if
(
debug
)
console
.
log
(
"We've got user create ack"
,
dack
,
roomname
,
sig
);
if
(
dack
.
err
){
console
.
log
(
"error in user.create"
,
dack
.
err
)
;
}
if
(
dack
.
err
){
console
.
log
(
"error in user.create"
,
dack
);
return
;
}
user
.
auth
(
roomname
,
sig
,
function
(
auth
){
if
(
debug
)
console
.
log
(
"We've got user auth ack"
,
auth
);
if
(
auth
.
err
){
console
.
log
(
'error in auth'
,
auth
.
err
);
}
if
(
auth
.
err
){
console
.
log
(
'error in auth'
,
auth
.
err
);
return
;
}
//console.log("auth",auth,roomname,sig);
Object
.
assign
(
obj
,{
pub
:
dack
.
pub
,
...
...
@@ -126,7 +126,7 @@ server.on("upgrade", async function(request, socket, head) {
}
}
if
(
gun
.
server
)
{
// Handle Request
gun
.
server
.
setMaxListeners
(
50
);
gun
.
server
.
handleUpgrade
(
request
,
socket
,
head
,
function
(
ws
)
{
if
(
debug
)
console
.
log
(
"connecting to gun instance"
,
gun
.
gun
.
opt
().
_
.
opt
.
ws
.
path
);
gun
.
server
.
emit
(
"connection"
,
ws
,
request
);
...
...
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