631 Commits

Author SHA1 Message Date
Jesse Gibson
ba673f73f8 Attempt reconnect on disconnect
Previously, the client websocket layer would only attempt a reconnection
if there were pending messages in the queue. Now it will always attempt
a reconnection, solving most of issue #259 (although not completely, as
reconnects are susceptible to race conditions).
2016-12-13 13:37:43 -07:00
Jesse Gibson
304265e193 Pass backoff options from constructor
The Client constructor supports backoff configuration. This commit
exposes it to the end developer via the `peers` options object, in the
`backoff` property.
Example:

Gun({
  peers: {
    'url.com/gun': {
      backoff: { max: 1000, factor: 0.2 }
    }
  }
})
2016-12-12 16:24:51 -07:00
Jesse Gibson
30fe844cab Check JSON support just once
Two separate modules (localStorage & websockets) ensured JSON was
globally defined. Since only one is needed to alert the user, the
other has been removed.
2016-12-12 16:10:39 -07:00
Jesse Gibson
bb65acab10 Merge branch '0.5' of https://github.com/amark/gun into 0.5 2016-12-12 15:12:41 -07:00
Jesse Gibson
01c93157cb Fix msg passing, add reconnect & backoff
Fixed broadcast storm caused by re-enveloping the same message and
re-emitting it (I passed the envelope to gun, not just the msg body).
Sockets will attempt an exponential reconnect if the message queue isn't
empty, otherwise they're still just lazy bums that only open when
needed.
JSONP wasn't working before I took on this project, but now it's
completely disconnected. Once it's working, it should go in the
`request` function as a websocket fallback.
2016-12-12 14:37:09 -07:00
Mark Nadal
69d1e81fc9 Update gun.js 2016-12-09 18:13:25 -08:00
hillct
c5f7b6283b Merge pull request #289 from hillct/feature/herokuDeployButton
Feature/heroku deploy button
2016-12-03 14:47:36 -05:00
hillct
dda4ac3aaf Very simple addition of deploy to Heroku button
Typo corrections
2016-12-03 14:45:28 -05:00
hillct
97eaea6a75 BasicDocker Button deployment with template app.json file 2016-12-03 14:13:18 -05:00
Jesse Gibson
b352cd742a Update client WebSocket plugin
Lovely little abstraction layer over websockets sends messages using
gun's new envelope system. Exponential backoff has not been
implemented yet. If the socket fails to connect, it won't retry (yet).
Also, this update left some dead code with the jsonp implementation.
Soon that should be ported over to the new envelope system too, but now
it's disconnected from gun.
2016-12-01 16:51:35 -07:00
hillct
968ec73aea Removed extraneous merge conflict marker 2016-12-01 03:20:22 -05:00
hillct
84f8cd0661 Merge pull request #288 from hillct/0.5
Just a little cleanup go get #287 to merge cleanly
2016-12-01 01:40:11 -05:00
hillct
b13000c40c Merge branch 'hillct-feature/dockerHooks' into 0.5 2016-12-01 01:30:19 -05:00
hillct
7ae8011c00 Conflict Cleanup 2016-12-01 01:12:40 -05:00
hillct
6b78b2ee91 Fixed Vendor Name 2016-12-01 00:57:48 -05:00
hillct
9fe11f6e9f Added local Docker hook usage example 2016-12-01 00:53:08 -05:00
hillct
237b445ebc Merge branch 'feature/dockerHooks' of github.com:hillct/gun into feature/dockerHooks 2016-12-01 00:14:10 -05:00
hillct
ba1ca8f54f Made the Docker Hub Automated build hook usable offline via 'npm docker'
Incorporated the unbuild step into the prepublish lifecycle workflow
Assured that /src files from Unbuild will never be comitted accidentally
Updated the uglify-js depencency and prepublish script for module rename
2016-12-01 00:11:38 -05:00
hillct
fbbd5d5899 Commit Badge from Microbadger 2016-11-30 22:06:37 -05:00
hillct
6d98b19c67 Dwitched to an older style git call, to get the repo URL 2016-11-30 20:04:27 -05:00
hillct
967bc972f7 Alpine based Docker image, metadata labels & Autobuild hooks 2016-11-30 19:02:28 -05:00
Mark Nadal
dd72a24740 Merge branch '0.5' of https://github.com/amark/gun into 0.5 2016-11-29 20:20:32 -08:00
Mark Nadal
111d0f5bda instance specific dedup for @d3x0r 2016-11-29 20:19:59 -08:00
hillct
0886ab357e Quick fix Restoring the Gun Logo 2016-11-29 20:22:57 -05:00
hillct
fbb8bbccb1 Merge pull request #286 from hillct/feature/DockerHub
DockerHub Documentation and sugar
2016-11-29 19:40:36 -05:00
hillct
45eb39ff29 Documentation for Docker Hub 2016-11-29 19:37:10 -05:00
hillct
cb397aeb8b Merge pull request #3 from amark/0.5
0.5 catchup
2016-11-29 19:20:06 -05:00
Mark Nadal
bd960b4d67 thanks to @Stefdv #284 2016-11-29 11:35:20 -08:00
Mark Nadal
ce32d8414b ahem, thank you d3x0r 2016-11-28 20:31:27 -08:00
Mark Nadal
71f15e21c6 Merge branch '0.5' of https://github.com/amark/gun into 0.5 2016-11-28 19:41:11 -08:00
Mark Nadal
3e2bf996fa final touches 2016-11-28 19:40:39 -08:00
Mark Nadal
9abe3fb75f fix for d3x0r and Stefdv 2016-11-28 17:57:20 -08:00
Mark Nadal
dff24e2578 Merge pull request #283 from hillct/feature/withBuildMinified
Minify Gun at package publish-time
2016-11-28 11:07:53 -07:00
Mark Nadal
4526ffda52 Merge pull request #281 from PsychoLlama/0.5
Add envelope-system server sync
2016-11-28 10:59:43 -07:00
hillct
7c0c7f3605 Minify Gun at package publish-time 2016-11-27 13:04:37 -05:00
Jesse Gibson
4848493530 Add envelope-system server sync
Using gun's new envelope system (where routing and de-duplication happen
inside gun core), server-to-server synchronization has been
implemented.
However, it comes with this warning: the chain isn't yet ready and
you'll have difficulty reading or writing data via the chain.
2016-11-25 14:42:44 -07:00
Jesse Gibson
9d9dea2553 Add envelope plugin system
@amark made these changes, I'm just committing them.
2016-11-25 09:49:48 -07:00
Mark Nadal
c8e919f287 fix chain 2016-11-22 18:07:49 -08:00
Mark Nadal
42003cb82f Merge pull request #276 from PsychoLlama/s2s-sync
Optimistically open client sockets
2016-11-18 13:09:29 -07:00
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
70698112e4 Merge branch '0.5' of https://github.com/amark/gun into 0.5 2016-11-18 11:50:24 -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
Mark Nadal
2f0ecef341 Merge pull request #275 from eschapp/patch-1
Update README.md
2016-11-18 10:35:19 -07:00
Eric Schapp
186b237ea5 Update README.md
Just a quick typo fix.
2016-11-18 10:53:00 -06: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
Mark Nadal
bb2a49c088 Merge pull request #272 from colealbon/0.5
#271 one liner fix to console assign error
2016-11-16 19:52:56 -07:00
Cole Albon
1960d44598 Merge pull request #1 from colealbon/colealbon-patch-1
#271 one liner fix error while assigning console
2016-11-16 19:15:07 -07:00
Cole Albon
86a5abd550 #271 one liner fix error while assigning console 2016-11-16 19:14:31 -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