4.4.0
版本发布时间: 2021-11-18 21:20:44
socketio/socket.io最新发布版本:2.5.1(2024-06-19 17:36:33)
Bug Fixes
- only set 'connected' to true after middleware execution (02b0f73)
Features
- add an implementation based on uWebSockets.js (c0d8c5a)
const { App } = require("uWebSockets.js");
const { Server } = require("socket.io");
const app = new App();
const io = new Server();
io.attachApp(app);
io.on("connection", (socket) => {
// ...
});
app.listen(3000, (token) => {
if (!token) {
console.warn("port already in use");
}
});
- add timeout feature (f0ed42f)
socket.timeout(5000).emit("my-event", (err) => {
if (err) {
// the client did not acknowledge the event in the given delay
}
});
interface SocketData {
name: string;
age: number;
}
const io = new Server<ClientToServerEvents, ServerToClientEvents, InterServerEvents, SocketData>();
io.on("connection", (socket) => {
socket.data.name = "john";
socket.data.age = 42;
});
Links:
- Diff: https://github.com/socketio/socket.io/compare/4.3.2...4.4.0
- Client release: 4.4.0
- engine.io version:
~6.1.0
(diff) - ws version:
~8.2.3