Cleanup; fix STUN servers
This commit is contained in:
parent
e9eeea48e5
commit
6317c25b10
3 changed files with 19 additions and 17 deletions
|
@ -10,7 +10,7 @@ class ServerConnection {
|
||||||
if (this._isConnected()) return
|
if (this._isConnected()) return
|
||||||
const ws = new WebSocket(this._endpoint());
|
const ws = new WebSocket(this._endpoint());
|
||||||
ws.binaryType = 'arraybuffer';
|
ws.binaryType = 'arraybuffer';
|
||||||
ws.onopen = e => console.log('WS: server connection opened');
|
ws.onopen = e => console.log('WS: server connected');
|
||||||
ws.onmessage = e => this._onMessage(e.data);
|
ws.onmessage = e => this._onMessage(e.data);
|
||||||
ws.onclose = e => this._onDisconnect();
|
ws.onclose = e => this._onDisconnect();
|
||||||
ws.onerror = e => console.error(e);
|
ws.onerror = e => console.error(e);
|
||||||
|
@ -18,7 +18,7 @@ class ServerConnection {
|
||||||
clearTimeout(this._reconnectTimer);
|
clearTimeout(this._reconnectTimer);
|
||||||
}
|
}
|
||||||
|
|
||||||
_isConnected(){
|
_isConnected() {
|
||||||
return this._socket && this._socket.readyState === this._socket.OPEN;
|
return this._socket && this._socket.readyState === this._socket.OPEN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -243,7 +243,7 @@ class RTCPeer extends Peer {
|
||||||
_createChannel() {
|
_createChannel() {
|
||||||
const channel = this._peer.createDataChannel('data-channel', { reliable: true });
|
const channel = this._peer.createDataChannel('data-channel', { reliable: true });
|
||||||
channel.binaryType = 'arraybuffer';
|
channel.binaryType = 'arraybuffer';
|
||||||
channel.onopen = e => this._onChannelOpened(e)
|
channel.onopen = e => this._onChannelOpened(e);
|
||||||
this._peer.createOffer(d => this._onDescription(d), e => this._onError(e));
|
this._peer.createOffer(d => this._onDescription(d), e => this._onError(e));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -466,16 +466,17 @@ window.isRtcSupported = !!(window.RTCPeerConnection || window.mozRTCPeerConnecti
|
||||||
|
|
||||||
RTCPeer.config = {
|
RTCPeer.config = {
|
||||||
'iceServers': [{
|
'iceServers': [{
|
||||||
urls: 'stun:stun.stunprotocol.org:3478'
|
urls: 'stun:stun.stunprotocol.org:3478'
|
||||||
}, {
|
}, {
|
||||||
urls: 'stun:stun.l.google.com:19302'
|
urls: 'stun:stun.l.google.com:19302'
|
||||||
}, {
|
}, {
|
||||||
urls: 'turn:turn.bistri.com:80',
|
url: 'turn:192.158.29.39:3478?transport=tcp',
|
||||||
credential: 'homeo',
|
credential: 'JZEOEt2V3Qb0y27GRntt2u2PAYA=',
|
||||||
username: 'homeo'
|
username: '28224511:1379330808'
|
||||||
}, {
|
}, {
|
||||||
urls: 'turn:turn.anyfirewall.com:443?transport=tcp',
|
urls: 'turn:turn.anyfirewall.com:443?transport=tcp',
|
||||||
credential: 'webrtc',
|
credential: 'webrtc',
|
||||||
username: 'webrtc'
|
username: 'webrtc'
|
||||||
}]
|
}
|
||||||
|
]
|
||||||
}
|
}
|
|
@ -335,8 +335,8 @@ class Notifications {
|
||||||
constructor() {
|
constructor() {
|
||||||
// Check if the browser supports notifications
|
// Check if the browser supports notifications
|
||||||
if (!('Notification' in window)) return;
|
if (!('Notification' in window)) return;
|
||||||
|
|
||||||
// Check whether notification permissions have already been granted
|
// Check whether notification permissions have already been granted
|
||||||
|
|
||||||
if (Notification.permission !== 'granted') {
|
if (Notification.permission !== 'granted') {
|
||||||
this.$button = $('notification');
|
this.$button = $('notification');
|
||||||
this.$button.removeAttribute('hidden');
|
this.$button.removeAttribute('hidden');
|
||||||
|
@ -364,6 +364,7 @@ class Notifications {
|
||||||
vibrate: [200, 100, 200, 100, 200, 100, 400],
|
vibrate: [200, 100, 200, 100, 200, 100, 400],
|
||||||
}
|
}
|
||||||
if (serviceWorker && serviceWorker.showNotification) {
|
if (serviceWorker && serviceWorker.showNotification) {
|
||||||
|
// android doesn't support "new Notification" if service worker is installed
|
||||||
return serviceWorker.showNotification(message, config);
|
return serviceWorker.showNotification(message, config);
|
||||||
} else {
|
} else {
|
||||||
return new Notification(message, config);
|
return new Notification(message, config);
|
||||||
|
|
|
@ -84,7 +84,7 @@ class SnapdropServer {
|
||||||
_leaveRoom(peer) {
|
_leaveRoom(peer) {
|
||||||
// delete the peer
|
// delete the peer
|
||||||
this._cancelKeepAlive(peer);
|
this._cancelKeepAlive(peer);
|
||||||
if (!this._rooms[peer.ip]) return;
|
if (!this._rooms[peer.ip] || !this._rooms[peer.ip][peer.id]) return;
|
||||||
|
|
||||||
delete this._rooms[peer.ip][peer.id];
|
delete this._rooms[peer.ip][peer.id];
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue