Skip to content

Commit

Permalink
fix: multi PWA support on one device; closes #300
Browse files Browse the repository at this point in the history
  • Loading branch information
ivelin committed Apr 5, 2021
1 parent 0c523c3 commit 6b110bd
Show file tree
Hide file tree
Showing 5 changed files with 171 additions and 135 deletions.
2 changes: 1 addition & 1 deletion .theia/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"editor.autoSave": "off"
"editor.autoSave": "on"
}
208 changes: 105 additions & 103 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 8 additions & 2 deletions src/remote/peer-fetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,17 @@ export class PeerFetch {
// update request-response map entry with this response
const pair = peerFetch._requestMap.get(ticket)
if (pair) {
// we expect the remote peer to respond with two consequetive data packates
// the first one containing the http header info
// and the second contatning the http body
if (!pair.response) {
console.debug('Processing response header')
// this is the first data message from the responses
const header = peerFetch.jsonify(data)
if (header.status === 202) {
if (header.status === undefined) {
console.warn('Expected http header packet with status attribute.', { ticket, header })
console.warn('Remote peer may not be using a compatible protocol.')
} else if (header.status === 202) {
console.debug('Received keepalive ping')
// server accepted the request but still working
// ignore and keep waiting until result or timeout
Expand Down Expand Up @@ -267,7 +273,7 @@ export class PeerFetch {
}

async _receiveResponse (ticket) {
const timeout = 10 * 60 * 1000 // 10 minutes
const timeout = 20 * 1000 // 10 seconds
const timerStart = Date.now()
let timeElapsed = 0
let response = null
Expand Down
1 change: 1 addition & 0 deletions src/store/action-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ export const PEER_CONNECT = 'peerConnect'
export const PEER_AUTHENTICATE = 'peerAuthenticate'
export const REMOVE_REMOTE_PEER_ID = 'removeRemotePeerId'
export const CHANGE_REMOTE_PEER_ID = 'newRemotePeerId'
export const HANDLE_PEER_CONNECTION_ERROR = 'handlePeerConnectionError'
Loading

0 comments on commit 6b110bd

Please sign in to comment.