mirror of
https://github.com/Leo501/CocosCreatorTutorial.git
synced 2026-05-09 15:18:40 +08:00
修改文件
This commit is contained in:
@@ -27,6 +27,7 @@ cc.Class({
|
||||
emitter.on('test_2', this.onTest_2);
|
||||
emitter.emit('test_1', 1, 1, 1);
|
||||
emitter.emit('test_2', 1, 1, 1);
|
||||
emitter.off('test_1', this.onTest_1);
|
||||
},
|
||||
|
||||
|
||||
@@ -45,4 +46,4 @@ cc.Class({
|
||||
update: function (dt) {
|
||||
|
||||
},
|
||||
});
|
||||
});
|
||||
@@ -1,14 +1,11 @@
|
||||
import { parse } from "path";
|
||||
import { eventNames } from "cluster";
|
||||
|
||||
let netConfig = {};
|
||||
netConfig.host = 'localhost';
|
||||
netConfig.port = '8181';
|
||||
|
||||
var NetControl = {
|
||||
_sock: {}, //当前的webSocket的对象
|
||||
sendTempArr: [],//发送数组
|
||||
handlers: [],//
|
||||
_sock: {}, //当前的webSocket的对象
|
||||
sendTempArr: [], //发送数组
|
||||
handlers: [], //
|
||||
connect() {
|
||||
if (this._sock.readyState !== 1) {
|
||||
//重新连接
|
||||
@@ -50,7 +47,10 @@ var NetControl = {
|
||||
},
|
||||
|
||||
send(event, data) {
|
||||
let newData = JSON.stringify({ event: event, data: data });
|
||||
let newData = JSON.stringify({
|
||||
event: event,
|
||||
data: data
|
||||
});
|
||||
//是否能发送
|
||||
if (this._sock.readyState !== 1) {
|
||||
console.log('sendTempArr');
|
||||
@@ -67,7 +67,7 @@ var NetControl = {
|
||||
* @param {*} fn
|
||||
*/
|
||||
addHandler(event, fn) {
|
||||
console.log('addHandler',event);
|
||||
console.log('addHandler', event);
|
||||
if (this.handlers[event]) {
|
||||
console.log("event:" + event + "' handler has been registered.");
|
||||
return;
|
||||
@@ -82,7 +82,7 @@ var NetControl = {
|
||||
},
|
||||
|
||||
removeHandler(event) {
|
||||
console.log('removeHandler',event);
|
||||
console.log('removeHandler', event);
|
||||
let handler = this.handlers[event];
|
||||
if (handler) {
|
||||
handler = null;
|
||||
@@ -90,7 +90,7 @@ var NetControl = {
|
||||
},
|
||||
|
||||
removeAllHandler() {
|
||||
console.log('removeAllHandler',event);
|
||||
console.log('removeAllHandler', event);
|
||||
this.handlers = {};
|
||||
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user