Server sample
Using the WebSocket Server sample bundle
The WebSocket-server sample bundle in samples/websocket-server shows how to set up a simple WebSocket server that will relay all incoming messages to all connected clients.
Prerequisites
- Working NodeCG & nodecg-io installation
Configure the websocket-server sample bundle
-
Start nodecg with nodecg-io installed. The websocket-server bundle is currently part of it so it should also be loaded.
-
Go to the
nodecg-iotab in the nodecg dashboard. -
Login using your password. If this is your first run, then enter the password with which you want to encrypt your configurations and credentials.
-
Create a new ws-server service instance using the left upper menu.
-
Enter a port for the server. This has to be a number from 0 to 65535.
The created instance should be automatically selected, if not select it in the upper left menu. Enter your port in monaco (the text-editor on the right) in this format:
{ "port": 7777 }After entering it, click save.
-
Set the created ws-server service instance to the service dependency of the ws-server bundle.
-
A websocket-server has been started at the specified port.