转到主要内容

· Une minute de lecture
Damien Arrachequesne

Hello everyone!

I'm happy to announce that Socket.IO is now compatible with Deno, which is a runtime for JavaScript and TypeScript written in Rust.

Usage:

import { serve } from "https://deno.land/std@0.150.0/http/server.ts";
import { Server } from "https://deno.land/x/socket_io@0.1.1/mod.ts";

const io = new Server();

io.on("connection", (socket) => {
console.log(`socket ${socket.id} connected`);

socket.emit("hello", "world");

socket.on("disconnect", (reason) => {
console.log(`socket ${socket.id} disconnected due to ${reason}`);
});
});

await serve(io.handler(), {
port: 3000,
});

And then run with:

$ deno run --allow-net index.ts

The API is very similar to the one exposed by the Node.js implementation.

Next steps:

  • client implementation
  • compatibility with the Node.js ecosystem (msgpack parser, adapters, admin UI, ...)

Feedback is welcome!