我有一个关于mootools的之间的集成问题,socket.io客户端socket.io:如何整合与MooTools的
假设: - 其中有一个socket.io的node.js开发的服务器应用程序监听
我想定义一个类来管理与服务器的连接,客户端socket.io必须驻留在这个类中。
其实我能够从这个类发送连接,但我无法管理推事件。如何更正此代码?
var Push = new Class({
Implements: [Events],
initialize : function() {
this.socketServer = '192.168.1.3';
this.listeningPort = '8080';
this.socketIoUrl = 'http://'.concat(this.socketServer,':', this.listeningPort);
//
this.socketIO = io.connect(this.socketIoUrl, {
'connect timeout' : 500,
'reconnect' : false,
'reconnection delay' : 0,
'reopen delay' : 500,
'max reconnection attempts' : 0
});
// Attach Socket.io events
this.attachEvents();
// Creating a socket.io room
this.socketIO.emit('create', this.filterName);
},
// SOCKET.IO EVENTS
attachEvents : function() {
socketIO.on = function(e) {
log.info('aaa');
socket.on('disconnect', function() {
log.error("SOCKET.IO CLIENT disconnected");
this.fireEvent("disconnect", [ e.data, e ]);
});
socket.on('connect_failed', function() {
log.error("SOCKET.IO connection failed ");
this.fireEvent("connect_failed", [ e.data, e ]);
});
socket.on('message', function() {
log.debug(e.data);
processMessage(e.data);
this.fireEvent("message", [ e.data, e ]);
});
}.bind(this)
return this
}
});
看来,你的问题不是由socket.io或mootools引起的... – Inferpse 2014-09-29 15:41:13
另一次我会多加注意带来很多元素,谢谢。 – 2014-09-29 19:45:18