ScaleSocket

Turn any code into a multiplayer websocket server.
Fast

Written with performance in mind

Simple

Follows the unix philosophy

Open source

With a proven track record

What it is.

ScaleSocket is a command-line tool for serving a binary or a script over websockets. If you are a programmer and need to build a collaborative server, ScaleSocket might be the tool for you.

To use it, you start your script using ScaleSocket and it maps the standard input and output streams to a websocket.

Furthermore, it supports rooms. Multiple websocket connections to the same URL will be routed to the same process. It makes building multiplayer apps, collaborative editing, and games a breeze.

Here's an image of how that looks:

ScaleSocket high level architecture diagram
High level architecture diagram. ScaleSocket listens for websocket connections and spawns backend processes running your code. All clients in a room are routed to the same process.

What it looks like.

ScaleSocket is language agnostic. A multiplayer websocket server in Typescript looks like this:

example-server.ts
import { createInterface } from 'readline';

const onReceive = (data: string) => {
  // Messages logged to stdout are sent to the client via the websocket
  console.log("Hello from the server")
  // Messages logged to stderr are not sent
  console.error("Received websocket data:", data);
}

// Messages are received by reading lines from stdin
createInterface({ input: process.stdin })
  .on('line', (line: string) => onReceive(line.trim()));

Start the server by wrapping Node.js in ScaleSocket. Here we use Node.js to run Typescript natively.

terminal
$ scalesocket node -- --experimental-strip-types ./example-server.mts
    [INFO] listening at 0.0.0.0:9000

Then connect as many clients as you want to a room at localhost:9000/example-room. For example, using wscat:

terminal
$ npm install -g wscat
added 9 packages in 142ms

$ wscat -c "ws://localhost:9000/example-room"
Connected (press CTRL+C to quit)
> Hello world
< Hello from the server

Getting started.