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).
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 }
}
}
})
Two separate modules (localStorage & websockets) ensured JSON was
globally defined. Since only one is needed to alert the user, the
other has been removed.
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.
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.
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
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.
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.
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.
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.
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.