Achieve_rooms is a very efficient ultralight-weight rooms program for use with the Achieve server and WS Websockets.
!important: Despite instructions at npmjs.com, I have only been successful installing WS globally.
Requirements:
- Node.js installed.
- Install Achieve for HTTP/S/2.
- Install WS globally for Websockets.
- Install achieve_rooms (npm i achieve_rooms)
Quick Start
There is a quick start configuration / startup file available at Github: achieve_quick_start The quick start is configured to use rooms with the WS websocket app and Achieve server. To learn to customize for other uses, visit the npm pages for each application.
Using achieve_rooms
Once you have installed the components, read comments in achieve_quick_start.js and set file paths appropriately. When ready,
run node achieve_quick_start
.
To join a room, add a room name to the URI that is used in the websocket connection request, for example:
ws = new Websocket("ws://example.com:8440?room=myroom687");
This works reguardless of language used. Your connection will join the room when the connection request is made. If the room does not yet exist, it will be created. When everyone in a room disconnects, the room is deleted. If you do not specify a room, you will be in the lobby.
Specifying the room with the connection request helps make achieve_rooms run faster. Identifying and registering in a room happens only once. The room is associated with the connection itself, where it is directly, quickly and easily accessed by achieve_rooms. Room information is never needed with any message you send.
The other components
Achieve is a modern, high-performance, developer-friendly HTTP/S/2 web server. WS is advertised as being the fastest websocket server available for node. The quick start file mentioned above uses the "noserver" option for WS, which means that Achieve and WS use the same port numbers. This avoids problems with CORS. I have been using this combination for years, with great satisfaction.
Copyright and License
copyright © 2022, Roger F. Gay, may be freely distributed with the MIT license