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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@sametnurel/socket-io-game-server

v0.0.8

Published

A lightweight, real-time multiplayer game server built with Socket.IO.

Downloads

15

Readme

🎮 Socket.IO Game Server

A modular, TypeScript-based Socket.IO game server framework, designed for managing real-time multiplayer games with a clean separation of concerns.

NPM Version
License: MIT
Build


📦 Installation

npm install @sametnurel/socketio-game-server

🚀 Features

  • 🔌 WebSocket connection management via Socket.IO
  • 🧩 Message handling using the Command pattern
  • 🎮 Game instance lifecycle management
  • 🗂 Singleton-based global managers
  • 🔧 Easily extensible for various game types

🧱 Architecture Overview

+----------------+        +-------------------+
|  Socket.IO     |<------>|  ConnectionManager|
+----------------+        +-------------------+
                             |
                             v
                     +------------------+
                     |   IOManager      |
                     +------------------+
                             |
                             v
                     +------------------+
                     |   GameManager    |
                     +------------------+
                             |
                             v
                   +----------------------+
                   |  Game / Player Logic |
                   +----------------------+

📡 ConnectionManager

Manages active connections and maps sockets to user IDs.

ConnectionManager.init(new MyConnectionManager());

export class MyConnectionManager extends ConnectionManager {
  initCommands() {
    .
    .
    .
    this.initCommand(SoloTestMessages.InitPlayer, new InitPlayerCommand());
    this.initCommand(SoloTestMessages.Disconnect, new DisconnectCommand());
    this.initCommand(SoloTestMessages.LobbyChat, new LobbyChatCommand());
    this.initCommand(SoloTestMessages.ChallengeUser, new ChallengeCommand());
    .
    .
    .
  }
}
  • Auto-registers event listeners per socket
  • Maps userId ↔ connectionId
  • Dispatches messages to BaseCommand handlers

🎮 GameManager

Manages the lifecycle of game instances.

GameManager.init(new MyGameManager());
const game = GameManager.getInstance().create();
  • Unique game ID generation
  • Tracks all active games
  • Supports custom game cleanup via clearGame()

🔄 IOManager

Initializes the HTTP + WebSocket server.

IOManager.init();
  • Broadcast messages to rooms:
IOManager.instance.broadcastToGame(gameId, Messages.UPDATE, payload);

🧩 BaseCommand

Extendable class to encapsulate message handling logic.

class JoinGameCommand extends BaseCommand<MyGameManager, MyConnectionManager> {
  handle(socket, conn, msg) {
    const game = this.gameManager.getGame(msg.gameId);
    // game logic...
  }
}
  • Receives socket, Connection, and message
  • Access to all managers

📄 Example Project Structure

src/
├── base/
│   └── BaseCommand.ts
├── components/
│   ├── Connection.ts
│   └── Game.ts
├── managers/
│   ├── ConnectionManager.ts
│   ├── GameManager.ts
│   └── IOManager.ts
└── utility/
    └── IdGenerator.ts

🛠 Extending for Your Game

  1. Subclass GameManager, ConnectionManager
  2. Implement your Game, Player, Commands
  3. Register commands via initCommands()
  4. Run server using IOManager.init()

📜 License

Samet Nurel