我想这样做,以便socket.io一次只允许来自同一会话的1个连接。我将如何访问会话ID?
var express = require("express"),
app = express(),
http = require("http").Server(app),
io = require("socket.io")(http),
io.on("connection", function (socket) {
});
答案 0 :(得分:1)
会话的唯一标识符是this documnet的socket.id
var express = require("express"),
app = express(),
http = require("http").Server(app),
io = require("socket.io")(http),
io.on("connection", function (socket) {
console.log(socket.id);
});