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
8e77cd37
authored
2020-04-30 22:03:37 +0700
by
Jabis Sevón
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
Merge remote-tracking branch 'origin/master'
2 parents
99644135
4fd4d8d6
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
3 deletions
gun-ws.js
mem.js
server.js
gun-ws.js
View file @
8e77cd3
;(
function
(){
var
Gun
=
(
typeof
window
!==
"undefined"
)?
window
.
Gun
:
require
(
'gun'
);
var
Gun
=
(
typeof
window
!==
"undefined"
)?
window
.
Gun
:
require
(
"gun/gun"
);
var
url
=
require
(
'url'
);
Gun
.
on
(
'opt'
,
function
mount
(
ctx
){
...
...
mem.js
View file @
8e77cd3
(
function
()
{
var
Gun
=
typeof
window
!==
"undefined"
?
window
.
Gun
:
require
(
"gun"
);
var
Gun
=
typeof
window
!==
"undefined"
?
window
.
Gun
:
require
(
"gun
/gun
"
);
Gun
.
on
(
"opt"
,
function
(
ctx
)
{
this
.
to
.
next
(
ctx
);
...
...
@@ -29,6 +29,24 @@
to
=
setTimeout
(
flush
,
opt
.
wait
||
1
);
});
ctx
.
on
(
"put"
,
function
(
at
)
{
this
.
to
.
next
(
at
);
Gun
.
graph
.
is
(
at
.
put
,
null
,
null
);
if
(
!
at
[
"@"
])
{
acks
[
at
[
"#"
]]
=
true
;
}
// only ack non-acks.
count
+=
1
;
if
(
count
>=
(
opt
.
batch
||
10000
))
{
return
flush
();
}
if
(
to
)
{
return
;
}
to
=
setTimeout
(
flush
,
opt
.
wait
||
1
);
var
id
=
at
[
'#'
]
ctx
.
on
(
'in'
,
{
"@"
:
id
,
ok
:
1
})
});
ctx
.
on
(
"get"
,
function
(
at
)
{
// this.to.next(at); //What does this do?
var
lex
=
at
.
get
,
...
...
server.js
View file @
8e77cd3
...
...
@@ -51,7 +51,7 @@ server.on("upgrade", async function(request, socket, head) {
gun
.
gun
=
new
Gun
({
peers
:
[],
// should we use self as peer?
localStorage
:
false
,
file
:
false
,
// "tmp/" + pathname,
file
:
false
,
radisk
:
false
,
multicast
:
false
,
ws
:
{
noServer
:
true
,
path
:
pathname
,
web
:
gun
.
server
},
...
...
@@ -67,6 +67,7 @@ server.on("upgrade", async function(request, socket, head) {
gun
.
server
.
emit
(
"connection"
,
ws
,
request
);
});
}
else
{
if
(
debug
)
console
.
log
(
"destroying socket"
,
pathname
);
socket
.
destroy
();
}
});
...
...
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