socket.io https://socket.io/ https://socket.io/docs/ What Socket.IO is Socket.IO is a library that enables real-time, bidirectional and event-based communication between the browser and the server. It consists of: a Node.js server: Source | API a Jav…
注:下面Demo的Server和Client都是纯后端. 并没有web页面. Server端代码: var express = require('express'); var app = express(); var server = require('http').createServer(app); var io = require('socket.io')(server); //定义变量,用来存储socket.如果是多进程的话,那么socket可以考虑存入redis中 var socket…