NodeJS + Android,Socket.io聊天,应用程序在离开聊天室的用户崩溃

我正在使用Socket.IO来创build一个聊天应用程序。 我是node.js和android的初学者。

实际上聊天工作,但是当一个人离开聊天室,任何聊天室,应用程序崩溃,我不得不重新启动它为另一个用户/用户能够再次聊天。

我得到的错误如下:

C:\ Users \ Tasos \ Desktop \ node.js server \ node_modules \ socket.io \ node_modules \ engine.io \ node_modules \ ws \ node_modules \ ultron \ index.js:80 if(this.ee._events.hasOwnProperty(event )){^

TypeError:this.ee._events.hasOwnProperty不是Ultron.remove(C:\ Users \ Tasos \ Desktop \ node.js服务器\ node_modules \ socket.io \ node_modules \ engine.io \ node_modules \ ws \ node_modules \ ultron.destroy(C:\ Users \ Tasos \ Desktop \ node.js server \ node_modules \ socket.io \ node_modules \ engine.io \ node_modules \ ws \ node_modules \ ultron \ index目录下的ultron \ index.js:80:27) WebSocket.cleanupWebsocketResources(C:\ Users \ Tasos \ Desktop \ node.js server \ node_modules \ socket.io \ node_modules \ engine.io \ node_modules \ ws \ lib \ WebSocket.js:851: (internal / process / next_tick.js:74:12)在endReadableNT(_stream_readable.js:974:12)处的Socket.emit(events.js:185:7)处的emitNone(events.js:91:20) 11)at process._tickCallback(internal / process / next_tick.js:98:9)

而我的应用程序是:

var app = require('express')(); var http = require('http').Server(app); var io = require('socket.io')(http); app.get('/', function(req, res){ res.sendFile('index.html', { root: __dirname }); }); // usernames of sockets which are currently connected to the server var usernames = {}; io.on('connection', function(socket){ console.log('a user connected'); socket.on('connect to room', function(roomName,username){ // we store the username in the socket session for this client socket.username = username; // add the client's username to the global list usernames[username] = username; socket.room = roomName; socket.join(roomName); console.log('User connected to specific room'); console.log(io.sockets); }); socket.on('chat message', function(msg){ console.log('Message:' + JSON.stringify(msg)); io.in(socket.room).emit('chat message', msg); console.log('Room name:' + socket.room); }); socket.on('disconnect', function(){ console.log('user disconnected'); socket.leave(socket.room); delete usernames[socket.username]; }); }); http.listen(1337, "0.0.0.0" , function(){ console.log('listening on localhost:1337'); }); 

有什么暗示在这里可能是错误的?

提前致谢。

       

网上收集的解决方案 "NodeJS + Android,Socket.io聊天,应用程序在离开聊天室的用户崩溃"