我正在尝试使用laravel开发一个实时聊天应用程序。我面临着一个问题。当我运行"node index.js“时,命令提示符中不断显示'A connection has made‘的信息。
我的index.js文件是:
var app = require('express')();
var server = require('http').Server(app);
var io = require('socket.io')(server);
server.listen(3000);
app.get('/', function(request, response){
response.sendFile(__dirname+ '/index.html');
});
io.on('connection', function(socket){
console.log('A connection has made');
// socket.on('chat.message', function(message){
// io.emit('chat.message', message);
// });
});
我的index.html页面是:
<!DOCTYPE html>
<html>
<head>
<title>Live Chat</title>
</head>
<body>
<div class="container" id="chat">
<h1> Chat System </h1>
</div>
<script type="text/javascript">
var socket = io();
</script>
</body>
</html>
我该怎么解决它呢?
https://stackoverflow.com/questions/51698594
复制相似问题