Browse Source

better disconnect error managment

les 3 years ago
parent
commit
8e72488417
4 changed files with 19 additions and 10 deletions
  1. 3 0
      app/worker-client.js
  2. 15 7
      app/worker.js
  3. 0 2
      package.json
  4. 1 1
      webpack.config.js

+ 3 - 0
app/worker-client.js

@@ -220,6 +220,9 @@ export class WorkerBasedMumbleClient extends EventEmitter {
       args[2] = args[2].map((id) => this._user(id))
       args[3] = args[3].map((id) => this._channel(id))
       args[4] = args[4].map((id) => this._channel(id))
+    } else if (name === 'error') {
+      this.emit('error', args)
+      return
     }
     args.unshift(name)
     this.emit.apply(this, args)

+ 15 - 7
app/worker.js

@@ -44,13 +44,21 @@ import 'subworkers'
 
   function registerEventProxy (id, obj, event, transform) {
     obj.on(event, function (_) {
-      postMessage({
-        clientId: id.client,
-        channelId: id.channel,
-        userId: id.user,
-        event: event,
-        value: transform ? transform.apply(null, arguments) : Array.from(arguments)
-      })
+      if (event === 'error') {
+        postMessage({
+          clientId: id.client,
+          event,
+          value: 'Error'
+        })
+      } else {
+        postMessage({
+          clientId: id.client,
+          channelId: id.channel,
+          userId: id.user,
+          event: event,
+          value: transform ? transform.apply(null, arguments) : Array.from(arguments)
+        })
+      }
     })
   }
 

+ 0 - 2
package.json

@@ -58,8 +58,6 @@
     "web-audio-buffer-queue": "^1.1.0",
     "webpack": "^4.44.2",
     "webpack-cli": "^3.3.12",
-    "webpack": "^4.42.1",
-    "webpack-cli": "^3.3.11",
     "worker-loader": "^2.0.0"
   },
   "optionalDependencies": {}

+ 1 - 1
webpack.config.js

@@ -2,7 +2,7 @@ var theme = '../themes/MetroMumbleLight'
 var path = require('path');
 
 module.exports = {
-  mode: 'development',
+  mode: 'production',
   entry: {
     index: [
       './app/index.js',