我有一個關於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