refactor: examples-browser (#508)

* refactor: examples-browser

* chore: add information to use signalling server

* chore: apply suggestions from code review

Co-Authored-By: Jacob Heun <jacobheun@gmail.com>

* chore: update deps

* docs: refactor libp2p browser example

* docs(examples): add back websockets and boostrap nodes

docs(examples): redo the browser readme

* fix: handle edge case of connections closing early

* chore: fix lint

* chore: update example deps and readme

* chore: update webrtc-star

* chore: apply suggestions from code review

Co-Authored-By: Alan Shaw <alan.shaw@protocol.ai>

Co-authored-by: Jacob Heun <jacobheun@gmail.com>
Co-authored-by: Alan Shaw <alan.shaw@protocol.ai>
This commit is contained in:
Vasco Santos
2020-01-24 17:43:56 +07:00
committed by Jacob Heun
parent d21b7ce4ff
commit 560d7084fe
14 changed files with 190 additions and 245 deletions

View File

@ -216,7 +216,10 @@ class Upgrader {
Muxer,
remotePeer
}) {
let muxer, newStream
let muxer
let newStream
// eslint-disable-next-line prefer-const
let connection
if (Muxer) {
// Create the muxer
@ -261,7 +264,7 @@ class Upgrader {
const _timeline = maConn.timeline
maConn.timeline = new Proxy(_timeline, {
set: (...args) => {
if (args[1] === 'close' && args[2] && !_timeline.close) {
if (connection && args[1] === 'close' && args[2] && !_timeline.close) {
connection.stat.status = 'closed'
this.onConnectionEnd(connection)
}
@ -276,7 +279,7 @@ class Upgrader {
}
// Create the connection
const connection = new Connection({
connection = new Connection({
localAddr: maConn.localAddr,
remoteAddr: maConn.remoteAddr,
localPeer: this.localPeer,