npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@rbxts/socket.io

v1.0.6

Published

A full implementation of Socket.IO on Roblox.

Readme

Socket.IO implementation on Roblox

This is a full implementation of Socket.IO on Roblox.

Because Roblox not support WebSocket, this implementation use HTTP long polling to communicate with server.

Limit

Roblox Limit 500 request per minute.

So this implementation will cache send packet and send request every 0.3 seconds.

you can see src/engine.io-client/transports/polling-roblox.ts

RunService.Heartbeat.Connect((dt) => {
	RobloxGlobalConfig.resetTime -= dt;
	if (RobloxGlobalConfig.resetTime < 0) {
		RobloxGlobalConfig.resetTime = RobloxGlobalConfig.REQUEST_TIMES_RESET_INTERVAL;
		RobloxGlobalConfig.requestTimes = 0;
	}
});
task.delay(0, () => {
	while (this.running) {
		this.flush();
		wait(0.3);
	}
});

Roblox request unstable.

So on Server side you need enable connection-state-recovery

import { createServer } from "http";
import { Server } from "socket.io";

const server = createServer();
const io = new Server(server, {
	// enable state recovery
	connectionStateRecovery: {
		// the backup duration of the sessions and the packets
		maxDisconnectionDuration: 2 * 60 * 1000,
		// whether to skip middlewares upon successful recovery
		skipMiddlewares: true,
	},
	pingInterval: 50000,
});
io.on("connection", (socket) => {
	if (socket.recovered) {
		// recovery was successful: socket.id, socket.rooms and socket.data were restored
	} else {
		// new or unrecoverable session
	}
});
const client = io.connect("http://localhost:3000", {
	reconnectionDelay: 10000, // defaults to 1000
	reconnectionDelayMax: 10000, // defaults to 5000
});
socket.on("connect", () => {
	if (socket.recovered) {
		// any event missed during the disconnection period will be received now
	} else {
		// new or unrecoverable session
	}
});

more long interval and send packet one time can reduce request times to prevent triggering roblox request restrictions.

You can config use RobloxGlobalConfig

// default config
export class RobloxGlobalConfig {
	/**
	 * Max request per minute
	 */
	public static MAX_REQUEST_PER_INTERVAL = 200;
	/**
	 * Interval to reset request times
	 */
	public static REQUEST_TIMES_RESET_INTERVAL = 60;
	/**
	 * Interval to flush packets
	 */
	public static FLUSH_PACKET_INTERVAL = 0.3;
}
// Modify config
RobloxGlobalConfig.MAX_REQUEST_PER_INTERVAL = 500;
RobloxGlobalConfig.FLUSH_PACKET_INTERVAL = 0.5;

Installation

npm install @rbxts/socket.io
yarn add @rbxts/socket.io
pnpm add @rbxts/socket.io

Usage

use example

import { io } from "@rbxts/socket.io";

const socket = io("http://localhost:3000");
socket.on("connect", () => {
	print("connected");
});
socket.on("disconnect", () => {
	print("disconnected");
});
socket.on("message", (message) => {
	print(message);
});

namespace support

import { RunService } from "@rbxts/services";
import { io } from "@rbxts/socket.io";

const manager = new Manager("http://localhost:3000");

const socket = manager.socket("/"); // main namespace
const adminSocket = manager.socket("/admin"); // admin namespace

socket.emit("players", { onlines: Players.GetChildren().size() });
adminSocket.on("kick", (uid, reason) => {
	Players.GetPlayerByUserId(uid)?.Kick(reason);
});