Show HN: ScaleSocket – Turn any script into a multiplayer WebSocket server
scalesocket.orgHi HN.
ScaleSocket is a command line tool that lets you to wrap any STDIO capable script or binary, and serve it over websockets. Clients then connect to rooms (channels) which have an unique URL (wss://example.com/exampleroom). Connecting to a room spawns a new process of the wrapped script. Subsequent websocket connections to the same room share the process.
I built ScaleSocket in order to be able to build multiplayer back-ends quickly. In the past, I have been experimenting with websocketd [1] to stream a command line application to the browser. It seemed to me that using that approach, i.e. spawning a process and streaming it over websockets, would make a nifty back-end for browser based multiplayer games. ScaleSocket takes that one step further, by supporting shared backend processes.
It's a pleasant approach to get started with, since no lobby server or netcode is required for making a multiplayer backend. ScaleSocket has been my prototyping tool for multiplayer games for some time now.
Isn't this just like netcat?
It's similar to running netcat in server mode, wrapping a script. It's even closer to doing that using websocat [1], whereby one does not have to do the websocket header juggling.
The main difference is that while netcat or websocat will spawn a new process for each connecting client, ScaleSocket has a concept of rooms (channels). For a room, a process is spawned once only. All clients connecting to the same room are routed to the same process. This is not straight forward to do using the forementioned tools.
There's a small comparison page [2] where I have mentioned some alternative tools.