From 6d558be11c67177868e5787ff75ea9a084cc0fe7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5var=20Aamb=C3=B8=20Fosstveit?= Date: Tue, 5 Nov 2019 09:46:12 +0100 Subject: [PATCH] Remove dependency, --- app/package.json | 1 - app/src/RoomClient.js | 52 +++++++++++++++++-------------------------- 2 files changed, 21 insertions(+), 32 deletions(-) diff --git a/app/package.json b/app/package.json index 191ff59..de631ba 100644 --- a/app/package.json +++ b/app/package.json @@ -9,7 +9,6 @@ "@material-ui/core": "^4.5.1", "@material-ui/icons": "^4.5.1", "bowser": "^2.7.0", - "create-torrent": "^4.4.1", "domready": "^1.0.8", "file-saver": "^2.0.2", "hark": "^1.2.3", diff --git a/app/src/RoomClient.js b/app/src/RoomClient.js index b6c0ea6..a10e55f 100644 --- a/app/src/RoomClient.js +++ b/app/src/RoomClient.js @@ -13,8 +13,6 @@ import * as stateActions from './actions/stateActions'; let WebTorrent; -let createTorrent; - let saveAs; let mediasoupClient; @@ -586,17 +584,8 @@ export default class RoomClient text : 'Starting file share.' })); - createTorrent(files, (err, torrent) => + this._webTorrent.seed(files, (torrent) => { - if (err) - { - return store.dispatch(requestActions.notify( - { - type : 'error', - text : 'Unable to upload file.' - })); - } - const existingTorrent = this._webTorrent.get(torrent); if (existingTorrent) @@ -604,20 +593,17 @@ export default class RoomClient return this._sendFile(existingTorrent.magnetURI); } - this._webTorrent.seed(files, (newTorrent) => - { - store.dispatch(requestActions.notify( - { - text : 'File successfully shared.' - })); + store.dispatch(requestActions.notify( + { + text : 'File successfully shared.' + })); - store.dispatch(stateActions.addFile( - this._peerId, - newTorrent.magnetURI - )); + store.dispatch(stateActions.addFile( + this._peerId, + torrent.magnetURI + )); - this._sendFile(newTorrent.magnetURI); - }); + this._sendFile(torrent.magnetURI); }); } @@ -1162,13 +1148,6 @@ export default class RoomClient 'webtorrent' )); - ({ default: createTorrent } = await import( - - /* webpackPrefetch: true */ - /* webpackChunkName: "create-torrent" */ - 'create-torrent' - )); - ({ default: saveAs } = await import( /* webpackPrefetch: true */ @@ -1219,6 +1198,17 @@ export default class RoomClient } }); + this._webTorrent.on('error', (error) => + { + logger.error('Filesharing [error:"%o"]', error); + + store.dispatch(requestActions.notify( + { + type : 'error', + text : `An error occured with file sharing` + })); + }); + this._screenSharing = ScreenShare.create(this._device); this._signalingSocket = io(this._signalingUrl);