gemercheung 3 лет назад
Родитель
Сommit
8bc8d330f2
5 измененных файлов с 73 добавлено и 82 удалено
  1. 47 77
      dist/js/index.js
  2. 1 1
      dist/js/index.js.map
  3. 7 0
      src/NetworkController.js
  4. 16 4
      src/Rtcp.js
  5. 2 0
      src/Socket.js

+ 47 - 77
dist/js/index.js

@@ -1,6 +1,6 @@
 /**
 * Name: Metaverse
-* Date: 2022/4/9
+* Date: 2022/4/11
 * Author: https://www.4dkankan.com
 * Copyright © 2022 4DAGE Co., Ltd. All rights reserved.
 * Licensed under the GLP license
@@ -971,14 +971,14 @@
     return _getPrototypeOf(o);
   }
 
-  function _createSuper$g(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$h(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
+  function _createSuper$f(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$g(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
 
-  function _isNativeReflectConstruct$h() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
+  function _isNativeReflectConstruct$g() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
 
   var Reporter = /*#__PURE__*/function (_EventEmitter) {
     _inherits(Reporter, _EventEmitter);
 
-    var _super = _createSuper$g(Reporter);
+    var _super = _createSuper$f(Reporter);
 
     function Reporter() {
       var _this;
@@ -1339,14 +1339,14 @@
     return AxiosCanceler;
   }();
 
-  function _createSuper$f(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$g(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
+  function _createSuper$e(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$f(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
 
-  function _isNativeReflectConstruct$g() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
+  function _isNativeReflectConstruct$f() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
 
   var Http1 = /*#__PURE__*/function (_EventEmitter) {
     _inherits(Http1, _EventEmitter);
 
-    var _super = _createSuper$f(Http1);
+    var _super = _createSuper$e(Http1);
 
     function Http1() {
       var _this;
@@ -2189,7 +2189,7 @@
     return Function.toString.call(fn).indexOf("[native code]") !== -1;
   }
 
-  function _isNativeReflectConstruct$f() {
+  function _isNativeReflectConstruct$e() {
     if (typeof Reflect === "undefined" || !Reflect.construct) return false;
     if (Reflect.construct.sham) return false;
     if (typeof Proxy === "function") return true;
@@ -2203,7 +2203,7 @@
   }
 
   function _construct(Parent, args, Class) {
-    if (_isNativeReflectConstruct$f()) {
+    if (_isNativeReflectConstruct$e()) {
       _construct = Reflect.construct;
     } else {
       _construct = function _construct(Parent, args, Class) {
@@ -2253,14 +2253,14 @@
     return _wrapNativeSuper(Class);
   }
 
-  function _createSuper$e(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$e(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
+  function _createSuper$d(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$d(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
 
-  function _isNativeReflectConstruct$e() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
+  function _isNativeReflectConstruct$d() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
 
-  var XverseError$1 = /*#__PURE__*/function (_Error) {
+  var XverseError = /*#__PURE__*/function (_Error) {
     _inherits(XverseError, _Error);
 
-    var _super = _createSuper$e(XverseError);
+    var _super = _createSuper$d(XverseError);
 
     function XverseError(e, t) {
       var _this;
@@ -2296,14 +2296,14 @@
     return XverseError;
   }( /*#__PURE__*/_wrapNativeSuper(Error));
 
-  function _createSuper$d(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$d(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
+  function _createSuper$c(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$c(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
 
-  function _isNativeReflectConstruct$d() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
+  function _isNativeReflectConstruct$c() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
 
   var TimeoutError = /*#__PURE__*/function (_XverseError) {
     _inherits(TimeoutError, _XverseError);
 
-    var _super = _createSuper$d(TimeoutError);
+    var _super = _createSuper$c(TimeoutError);
 
     function TimeoutError(e) {
       _classCallCheck(this, TimeoutError);
@@ -2312,16 +2312,16 @@
     }
 
     return _createClass(TimeoutError);
-  }(XverseError$1);
+  }(XverseError);
 
-  function _createSuper$c(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$c(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
+  function _createSuper$b(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$b(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
 
-  function _isNativeReflectConstruct$c() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
+  function _isNativeReflectConstruct$b() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
 
   var XverseAvatarManager = /*#__PURE__*/function (_EventEmitter) {
     _inherits(XverseAvatarManager, _EventEmitter);
 
-    var _super = _createSuper$c(XverseAvatarManager);
+    var _super = _createSuper$b(XverseAvatarManager);
 
     function XverseAvatarManager(e) {
       var _this;
@@ -2972,14 +2972,14 @@
     First: 1
   };
 
-  function _createSuper$b(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$b(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
+  function _createSuper$a(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$a(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
 
-  function _isNativeReflectConstruct$b() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
+  function _isNativeReflectConstruct$a() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
 
   var Camera = /*#__PURE__*/function (_EventEmitter) {
     _inherits(Camera, _EventEmitter);
 
-    var _super = _createSuper$b(Camera);
+    var _super = _createSuper$a(Camera);
 
     function Camera(e) {
       var _this;
@@ -3265,9 +3265,9 @@
     return Camera;
   }(EventEmitter);
 
-  function _createSuper$a(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$a(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
+  function _createSuper$9(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$9(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
 
-  function _isNativeReflectConstruct$a() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
+  function _isNativeReflectConstruct$9() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
 
   var numberFormat = new Intl.NumberFormat(window.navigator.language, {
     maximumFractionDigits: 0
@@ -3276,7 +3276,7 @@
   var Stats = /*#__PURE__*/function (_EventEmitter) {
     _inherits(Stats, _EventEmitter);
 
-    var _super = _createSuper$a(Stats);
+    var _super = _createSuper$9(Stats);
 
     function Stats(e) {
       var _this;
@@ -4579,14 +4579,14 @@
     return Signal;
   }();
 
-  function _createSuper$9(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$9(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
+  function _createSuper$8(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$8(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
 
-  function _isNativeReflectConstruct$9() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
+  function _isNativeReflectConstruct$8() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
 
   var ParamError$1 = /*#__PURE__*/function (_XverseError) {
     _inherits(ParamError, _XverseError);
 
-    var _super = _createSuper$9(ParamError);
+    var _super = _createSuper$8(ParamError);
 
     function ParamError(e) {
       _classCallCheck(this, ParamError);
@@ -4595,7 +4595,7 @@
     }
 
     return _createClass(ParamError);
-  }(XverseError$1);
+  }(XverseError);
 
   var MotionType$1 = {
     Walk: 'walk',
@@ -4687,49 +4687,6 @@
     return Timeout;
   }();
 
-  function _createSuper$8(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$8(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
-
-  function _isNativeReflectConstruct$8() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
-
-  var XverseError = /*#__PURE__*/function (_Error) {
-    _inherits(XverseError, _Error);
-
-    var _super = _createSuper$8(XverseError);
-
-    function XverseError(e, t) {
-      var _this;
-
-      _classCallCheck(this, XverseError);
-
-      _this = _super.call(this, t);
-      _this.code = e;
-      return _this;
-    }
-
-    _createClass(XverseError, [{
-      key: "toJSON",
-      value: function toJSON() {
-        return {
-          code: this.code,
-          message: this.message
-        };
-      }
-    }, {
-      key: "toString",
-      value: function toString() {
-        if (Object(this) !== this) throw new TypeError();
-        var t = this.name;
-        t = t === void 0 ? "Error" : String(t);
-        var r = this.message;
-        r = r === void 0 ? "" : String(r);
-        var n = this.code;
-        return r = n === void 0 ? r : n + "," + r, t === "" ? r : r === "" ? t : t + ": " + r;
-      }
-    }]);
-
-    return XverseError;
-  }( /*#__PURE__*/_wrapNativeSuper(Error));
-
   function _createSuper$7(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$7(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
 
   function _isNativeReflectConstruct$7() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
@@ -6329,7 +6286,7 @@
 
     var _super = _createSuper$5(Rtcp);
 
-    function Rtcp(e) {
+    function Rtcp(network) {
       var _this;
 
       _classCallCheck(this, Rtcp);
@@ -6347,7 +6304,7 @@
       _this.workers = null;
       _this.actived = !0;
       _this.heartbeat = null;
-      _this.network = e; //this.workers = new Workers(this,new Logger("decode")),
+      _this.network = network; //this.workers = new Workers(this,new Logger("decode")),
       //this.workers.registerLogger(new Logger("decode")),
 
       _this.workers = new Workers(_assertThisInitialized(_this));
@@ -6368,7 +6325,15 @@
           });
         }
 
-      });
+      }); //解决onIcecandidate 获取不了this
+
+      _this.onIcecandidate = _this.onIcecandidate.bind(_assertThisInitialized(_this));
+      _this.onIceStateChange = _this.onIceStateChange.bind(_assertThisInitialized(_this));
+      _this.setRemoteDescription = _this.setRemoteDescription.bind(_assertThisInitialized(_this));
+      _this.start = _this.start.bind(_assertThisInitialized(_this));
+      _this.flushCandidate = _this.flushCandidate.bind(_assertThisInitialized(_this));
+      _this.addCandidate = _this.addCandidate.bind(_assertThisInitialized(_this));
+      _this.disconnect = _this.disconnect.bind(_assertThisInitialized(_this));
       return _this;
     }
 
@@ -6518,7 +6483,9 @@
         this.connection = new RTCPeerConnection();
         var e = Date.now();
         this.connection.ondatachannel = function (t) {
-          logger.info("ondatachannel: ".concat(t.channel.label)), _this3.inputChannel = t.channel, _this3.inputChannel.onopen = function () {
+          logger.info("ondatachannel: ".concat(t.channel.label));
+          _this3.inputChannel = t.channel;
+          _this3.inputChannel.onopen = function () {
             var r;
             logger.info("The input channel has opened, id:", (r = _this3.inputChannel) == null ? void 0 : r.id), _this3.inputReady = !0, _this3.emit("rtcConnected"), _this3.network.room.currentNetworkOptions.reconnect || (logger.infoAndReportMeasurement({
               metric: "datachannelOpenedAt",
@@ -6556,6 +6523,7 @@
     }, {
       key: "sendStringData",
       value: function sendStringData(e) {
+        console.log('e', e);
         this.input(e);
       }
     }, {
@@ -6703,6 +6671,7 @@
       value: function startGame() {
         var _this2 = this;
 
+        debugger;
         return new Promise(function (e, t) {
           if (!_this2.rtcp.connected) return t(new InternalError("Game cannot load. Please refresh"));
           if (!_this2.rtcp.inputReady) return t(new InternalError("Game is not ready yet. Please wait"));
@@ -6778,6 +6747,7 @@
                   });
                   return _context2.abrupt("return", new Promise(function (t, r) {
                     _this3.rtcp.on("rtcConnected", function () {
+                      debugger;
                       _this3.setState("connected"), t();
                     }), _this3.rtcp.on("rtcDisconnected", function () {
                       logger.info("rtc disconnected"), _this3._state === "connecting" ? (_this3.setState("disconnected"), r(new InternalError("rtc connect failed"))) : (_this3.setState("disconnected"), logger.info("rtc disconnected, start to reconnect"), _this3.reconnect());

Разница между файлами не показана из-за своего большого размера
+ 1 - 1
dist/js/index.js.map


+ 7 - 0
src/NetworkController.js

@@ -5,6 +5,8 @@ import Rtcp from "./Rtcp.js"
 import NetworkMonitor from "./NetworkMonitor.js"
 import Stream from "./Stream.js"
 
+
+
 var workerSourceCode = `onmessage = function (event) {
     const data = event.data
     if (!data) return
@@ -72,12 +74,14 @@ export default class NetworkController extends EventEmitter {
     }
 
     startGame(){
+        debugger;
         return new Promise((e,t)=>{
             if (!this.rtcp.connected)
                 return t(new InternalError("Game cannot load. Please refresh"));
             if (!this.rtcp.inputReady)
                 return t(new InternalError("Game is not ready yet. Please wait"));
             this.socket.on("gameRoomAvailable", r=>{
+               
                 this.setState("connected"),
                 e(r),
                 this.rtcp.heartbeat.start()
@@ -110,11 +114,14 @@ export default class NetworkController extends EventEmitter {
         return this.connect(e).then(this.startGame)
     }
     async connect(e=!1) {
+     
         this.room.updateCurrentNetworkOptions({
             reconnect: e
         });
         return new Promise((t,r)=>{
+      
             this.rtcp.on("rtcConnected", ()=>{
+                debugger
                 this.setState("connected"),
                 t()
             }

+ 16 - 4
src/Rtcp.js

@@ -3,7 +3,7 @@ import Workers from "./Workers.js"
 import Heartbeat from "./Heartbeat.js"
  
 export default class Rtcp extends EventEmitter {
-    constructor(e) {
+    constructor(network) {
         super();
         this.connection = null
         this.inputChannel = null
@@ -17,7 +17,8 @@ export default class Rtcp extends EventEmitter {
         this.workers = null
         this.actived = !0
         this.heartbeat = null
-        this.network = e;
+        this.network = network;
+
         //this.workers = new Workers(this,new Logger("decode")),
         //this.workers.registerLogger(new Logger("decode")),
         this.workers = new Workers(this);
@@ -39,12 +40,21 @@ export default class Rtcp extends EventEmitter {
                 })
             }
         })
+        //解决onIcecandidate 获取不了this
+        this.onIcecandidate =this.onIcecandidate.bind(this)
+        this.onIceStateChange =this.onIceStateChange.bind(this)
+        this.setRemoteDescription =this.setRemoteDescription.bind(this)
+        this.start =this.start.bind(this)
+        this.flushCandidate = this.flushCandidate.bind(this)
+        this.addCandidate = this.addCandidate.bind(this)
+        this.disconnect =this.disconnect.bind(this)
     }
 
     onIcecandidate(e){
         if (e.candidate != null) {
             const t = JSON.stringify(e.candidate);
             logger.debug(`Got ice candidate: ${t}`),
+      
             this.network.socket.send({
                 id: "ice_candidate",
                 data: btoa(t)
@@ -144,8 +154,9 @@ export default class Rtcp extends EventEmitter {
         this.connection = new RTCPeerConnection;
         const e = Date.now();
         this.connection.ondatachannel = t=>{
-            logger.info(`ondatachannel: ${t.channel.label}`),
-            this.inputChannel = t.channel,
+            logger.info(`ondatachannel: ${t.channel.label}`);
+            this.inputChannel = t.channel;
+            
             this.inputChannel.onopen = ()=>{
                 var r;
                 logger.info("The input channel has opened, id:", (r = this.inputChannel) == null ? void 0 : r.id),
@@ -197,6 +208,7 @@ export default class Rtcp extends EventEmitter {
         this.inputChannel = null
     }
     sendStringData(e) {
+        console.log('e',e)
         this.input(e)
     }
     sendData(e) {

+ 2 - 0
src/Socket.js

@@ -151,6 +151,7 @@ export default class Socket extends EventEmitter {
         }
         ),
         e.addEventListener("message", t=>{
+        
             if (!t || this._hasTimeout || !this.connected)
                 return;
             let r = null;
@@ -163,6 +164,7 @@ export default class Socket extends EventEmitter {
             if (!r)
                 return;
             const n = r.id;
+            
             if (!!n)
                 switch (n !== "heartbeat" && logger.info(`receive ws frame: ${t.data}`),
                 n) {