Connects server websocket by event to gun.... (would have complicated with alternative websocket interfaces and protocol handlings... but left some comments about that)
if wsc doesn't previosuly exist, create a empty option block.
add option 'protocols' for wsc that can specify the optional protocols before the options.
Options will also only apply to node client websockets; (package 'ws'), browser websockets only take 1 with 1 optional parameter (being the list of protocols to connect with; so I added that optional param for compatibility.
I recently had to set options given to the websocket client especially
rejectUnauthorized {Boolean} Verify or not the server certificate.
for connecting to wss which are using self signed certs...
could also pass things like 'protocol' to differentiate a Gun websocket connection from some other websocket connection....
I don't know if maybe websock options should be a object in options instead ? To avoid namespace collision?
Older versions of npm don't support the caret version selector, which
seems to be failing Travis-CI gun build 649.1 & 649.2.
I've switched it to a more backwards-compatible version selector.
Sadly, I can't test if it works on my machine, since the node install
seems to fail on all versions prior to v4. Travis will just need to tell
us :)
Move E2E panic tests into their own dedicated folder so mocha won't
automatically attempt to run it. New npm script (`npm run e2e`) runs
those tests with mocha explicitly.
This solves a number of problems:
- Travis-CI can't run the panic tests without a selenium server, which
requires a ton more setup that simply hasn't been done yet.
- Selenium-webdriver doesn't support node < v4, and immediately fails
the build on those environments.
If at any point in the future we want those tests to run automatically,
here's what we'll need:
- Browserstack or SauceLabs tunneling and auth env variables.
- Bash script to detect node version and only install deps and run the
tests if the environment supports it.
Also, a number of tests had `.only` in front, preventing all the others
from running. They've been removed.
Running the unbuild step wipes out the src/.gitignore file. Instead,
now the root .gitignore file is told to ignore src/.
Prevents a scenario where you run unbuild, it wipes out the .gitignore
file, and `git status` shows all the new src files as untracked. A
developer could accidentally commit them without realizing it.
Previously constructor options were deeply copied, which caused
issues with 3rd party plugins when they pass "class" instances as
options (since instances were copied into POJOs, breaking the prototype
chain). Now it's shallow copied. Special treatment is still given for
the `peers` property.
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.