94 Commits

Author SHA1 Message Date
Jesse Gibson
6a63b46d2b Add max reconnect backoff
Sockets will try to reconnect upon disconnection with an exponentially
rising backoff (configurable). However, if it's unbounded, at a certain
point does it need to even try? Probably not. Instead there's now a
`max` option that defaults to a minute, and the backoff will never
exceed that time.
2016-11-18 12:49:58 -07:00
Jesse Gibson
2696b4cf88 Merge branch '0.5' into s2s-sync 2016-11-18 11:57:06 -07:00
Jesse Gibson
e402e3966e Optimistically open client sockets
Changes behavior from only opening sockets when absolutely necessary to
keeping them open for as long as possible. Key differences:
- Much higher success rate for messages sent from the connected server.
- Process no longer shuts down if nothing is done with gun, instead
  listens for incoming messages on client sockets.
Socket reconnect handle by Peer instances, meaning better handling for
deferred messages and predictable backoff.
The client.js logic has been significantly refactored. Among the
improvements, GET/PUT requests now respect the `peers` option for each
gun instance, only sending requests to the URLs listed.
2016-11-18 11:42:24 -07:00
Jesse Gibson
e8f8047cb6 Expose websocket events
The Peer "class" now extends EventEmitter. Listening to any websocket
events (e.g., "message", "close", "open", etc.) will not only subscribe
to the current websocket, but all future websockets. This provides a
much needed abstraction, since reconnection replaces the socket, which
would typically destroy your listeners.
2016-11-17 14:07:26 -07:00
Jesse Gibson
37696e1ada Prevent most broadcast storms
Better de-duplication on messages sent for GET and PUT requests,
allowing full circular connections without blowing up your computer.
Sadly, this broke some things against the previous version, so per
@amark's request I'm publishing so he can debug.
2016-11-16 16:40:14 -07:00
Jesse Gibson
f999e5f2ea Fix chain option search
If you're reading this commit history, please avert your eyes. 3
commits to fix this admittedly simple problem is more than my pride can handle.
The `gun.Back()` function was only searching for `opt`, not
`opt.file`. It would stop at the first mention of `opt` even if it
didn't have settings for `file`. Now it won't.
2016-11-15 16:20:18 -07:00
Jesse Gibson
e7162aa098 Reliably check file.js options
The FileJS module can be passed options in two ways, and this commit
ensures they're treated in the right way.
Previously, options passed as .put or .get parameters would be favored
over those used on the chain, even if `file` wasn't specified. Now, the
module will only use the method options if `file` is mentioned, falling
back to the chain options.
This was a mistake on my part with the first PR (#268), I failed to notice notice that edge case.
2016-11-15 13:10:00 -07:00
Jesse Gibson
ddf272bbb0 Allow greeting messages to be opt-out
If you use gun a bunch, you've probably noticed the messages like "Hello
wonderful person :)" and "WARNING: This file.js module...".
This PR allows you to silence them.
Use `Gun.log.off = true` to bring peace back to your workflow.
> **Note:** great when used with file watchers like nodemon."
2016-11-14 17:00:06 -07:00
Jesse Gibson
406276739a Merge pull request #268 from PsychoLlama/allow-file-json-opt-out
Allow opting out of file.json
2016-11-14 16:39:24 -07:00
Jesse Gibson
3e66aff985 Allow opting out of file.json
If the most recent gun options disable the file module, then it
won't try to read/write from the json. Previously it would. Also, now
you can override the behavior by passing `{ file: false }` as the
options in `gun.put`.
2016-11-14 16:31:45 -07:00
Jesse Gibson
ba43dcac17 Add server push
Pushes graph updates to connected clients, listening for
acknowledgements.
2016-11-14 13:40:55 -07:00
Jesse Gibson
e8194887e0 Add basic server get handling
Servers now dispatch requests to clients and listen for responses,
plugging them into gun.
2016-11-11 17:48:56 -07:00
Jesse Gibson
4cd2d434d1 Add websocket backoff/retry logic
New library handles websocket reconnection logic and queues messages
that were sent while offline.
2016-11-10 10:11:01 -07:00
Jesse Gibson
e36e78f532 Isolate websocket logic
WebSocket logic has it's own folder now, `wsp`.
2016-11-10 10:09:18 -07:00
Jesse Gibson
adbea08120 Add basic websocket logic
Servers will now try to initiate a connection using websockets if the
`peers` option is set. Currently, it'll either start throwing errors,
or generate a broadcasting storm. Still work to be done...
This marks a milestone of getting the servers to connect to each
other. Now to have those messages make sense. Committing so I
have an easy rollback point.
2016-10-26 14:52:28 -06:00
Jesse Gibson
6f8c99ccf1 Fix /gun.js route
The `wsp.server` logic was never making it to the /gun.js route. If the
browser is just sending a GET request for a the js file, it won't set
the upgrade property, and the server logic wouldn't let the request pass
if it didn't have that header.
I've simply moved the check below the file serving logic.
2016-10-18 13:54:59 -06:00
Allain Lalonde
81a48ff272 \r\n was incorrectly getting replaced with \r, which mangled things 2016-10-05 15:43:37 -04:00
d3x0r
a472f33e66 Check request for 'upgrade' being set
along with the path check, should check that the request is an upgrade before assuming to do anything with it really.
2016-09-30 16:54:06 -07:00
devel-pa
9098380a90 Put out of the way require polyfill. 2016-09-30 21:24:01 +02:00
devel-pa
b8025b207f Unbuilding structure. 2016-09-30 21:19:18 +02:00
Mark Nadal
347ac0ff37 Update wsp.js 2016-09-26 22:50:35 -07:00
Mark Nadal
2ce6c80521 fix crashing bug found by @d3x0r 2016-09-25 18:09:28 -07:00
Mark Nadal
cdbf06e9c4 pretty print data.json for @d3x0r 2016-09-25 13:41:14 -07:00
Mark Nadal
fa3d3eeff4 0.5 BETA TESTING 2016-09-25 13:06:29 -07:00
Mark Nadal
97449e9f28 into the meat of put 2016-08-03 16:58:15 -07:00
Mark Nadal
afc1c18304 significant internal refactor 2016-07-14 19:37:19 -07:00
Mark Nadal
b369d37731 bring opt updates in from master 2016-07-07 11:49:30 -07:00
Mark Nadal
ac761bf674 re-organize, add panic 2016-06-01 08:35:55 -07:00
Mark Nadal
08418ee836 realtime sync with 40 tests passing 2016-05-26 11:40:09 -07:00
Mark Nadal
3ff91ec42c add more tests 2016-05-25 14:26:29 -07:00
Mark Nadal
1fdd9cf89a 20% tests passing! Before testing server. 2016-05-25 13:11:06 -07:00
Mark Nadal
0f01d06975 25M+ ops/sec !!!!! 2016-05-10 17:08:33 -07:00
Mark Nadal
2d3572fe82 oye 2016-02-29 23:18:22 -08:00
Mark Nadal
cae7db93f5 dem refactor 2016-02-26 12:15:24 -08:00
Mark Nadal
7883bad67d oye 2016-02-15 13:56:23 -08:00
Mark Nadal
0acdb4e137 mid-sentence 2016-02-11 19:46:16 -08:00
Mark Nadal
4631200115 refinements on structuring 2016-02-11 08:11:37 -08:00
Mark Nadal
cec7e10133 Streaming demo
Major changes for the streaming demo, pushing to GitHub
2016-02-09 16:30:47 -08:00
Mark Nadal
c8fe8ae00c SPAM 2016-02-03 12:07:41 -08:00
Mark Nadal
a1bc9a27f2 switch to real work 2016-02-01 13:47:42 -08:00
Mark Nadal
c03b7d4e1e match update 2016-01-30 15:14:33 -08:00
Mark Nadal
7f44bed3d9 quick express fixes 2016-01-28 13:00:38 -08:00
Mark Nadal
93bf37b94d Merge branch 'master' into develop
# Conflicts:
#	README.md
#	gun.js
2016-01-26 12:59:10 -08:00
Mark Nadal
ce6ce34dce readme update 2016-01-26 12:41:29 -08:00
Mark Nadal
73aae8edf0 Update wsp.js 2016-01-11 16:13:17 -08:00
Mark Nadal
8f24dc9e2f Update wsp.js 2016-01-04 16:26:55 -08:00
Mark Nadal
59f20c2cbd couple fixes 2015-12-30 14:51:15 -08:00
Mark Nadal
8c0dae0176 server updated 2015-12-26 21:14:14 -08:00
Mark Nadal
ab138b5350 BREAKING 0.3 ONLY CORE MEMORY WORKS!
# Conflicts:
#	lib/file.js
2015-12-23 18:12:01 -08:00
Mark Nadal
6d15aa1e61 API 0.3 BREAKING CHANGES, TESTS PASSING 2015-12-22 01:56:41 -08:00