Skip to content
This repository was archived by the owner on Jun 8, 2021. It is now read-only.

fix(connection): fix connection crash when use without web browser #39

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/Connection/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import JsonEncoder from '../JsonEncoder/index.js'
* @returns {String}
*
*/
const wsProtocol = window.location.protocol === 'https:' ? 'wss' : 'ws'
const wsProtocol = window.location && window.location.protocol === 'https:' ? 'wss' : 'ws'

/**
* Connection class is used to make a TCP/Socket connection
Expand Down Expand Up @@ -135,8 +135,8 @@ export default class Connection extends Emitter {
*/
get shouldReconnect () {
return this._connectionState !== 'terminated' &&
this.options.reconnection &&
this.options.reconnectionAttempts > this._reconnectionAttempts
this.options.reconnection &&
this.options.reconnectionAttempts > this._reconnectionAttempts
}

/**
Expand Down