difenduandada
2024-12-31 34abe6963b344c882358274957f4b992456fee40
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
"use strict";
cc._RF.push(module, '22b707itTxINYKWjn3CpP90', 'basecontroller');
// Scripts/common/basecontroller.js
 
"use strict";
 
/*-----------------------------------------------------+
 * 控制处理类相关处理
 * @author whjing2012@163.com
 +-----------------------------------------------------*/
window.BaseController = cc.Class({
  "extends": BaseClass,
  ctor: function ctor() {
    if (this.constructor.instance) {
      throw new Error("不能重复实例化一个单例");
    }
 
    this.constructor.instance = this;
 
    if (this.initConfig) {
      this.initConfig();
    }
 
    if (this.registerEvents) {
      this.registerEvents();
    }
 
    if (this.registerProtocals) {
      this.registerProtocals();
    }
  },
  statics: {
    instance: null
  },
  RegisterProtocal: function RegisterProtocal(cmd, func) {
    gcore.SmartSocket.bindCmd(cmd, func.bind(this));
  },
  SendProtocal: function SendProtocal(cmd, data) {
    if (!cmd) {
      Log.error("发送失败,错误的协议号");
      return;
    }
 
    data = data || {};
    gcore.SmartSocket.send(cmd, data);
  }
}); // 实例化单利
 
BaseController.getInstance = function () {
  if (!this.instance) {
    new this();
  }
 
  return this.instance;
};
 
cc._RF.pop();