This repsitory demonstrates running the Needle Engine networking server on top of the node.js-based Express framework. The server can be run locally or hosted in the cloud.
For more information about networking in Needle Engine, please refer to the Needle Engine documentation.
- Install Node.js
- Do either of the following:
-
Option A – automatic setup
- Run
START_EXPRESS.bat
, which will install dependencies and then start the server on port 9001
- Run
-
Option B – manual setup
- Open the
/express
folder - run
npm i
- run
npm run dev
, which will start the server on port 9001
- Open the
-
-
Start the server using one of the options above.
-
The server console should print a message like
Websocket endpoint is wss://localhost:9001/socket**
-
Copy the base websocket URL, and paste it into the Needle Engine Networking component:
Set the Localhost field towss://localhost:9001
. -
Start your Needle Engine local server as usual. The browser console will contain a log like
Connected to networking backend wss://localhost:9001/socket
-
All network messages are now sent to the local server. The room state is stored in
/express/.data
as JSON files. The console will contain additional logs for users joining, leaving rooms, rooms being created and closed, and so on.
-
Click "Remix" in the bottom right corner
-
Wait for the server to start
-
Click on "Open in new window" in the top right corner of the Glitch UI
-
Copy the URL from the new window and paste it into the Needle Engine Networking component.
-
Select
Continuously deploy new revisions from a source repository
-
Click the
SET UP WITH CLOUD BUILD
button -
Select your source repository (it can be this repository or a fork)
-
Click
NEXT
-
Optionally change the branch that should trigger a build. By default it uses your main branch.
-
In
Build Type
selectGo, Node, ... Google Cloud's buildpacks
-
Enter the directory where the server is located. In this case
/express
-
Click
SAVE
-
Select a
Region
where your server should run -
Modify the Autoscaling options to your liking
-
Click
CREATE
-
You can now go to the google cloud builds page to see your server being deployed and it should shortly after be available on your cloud run URL
You can enter your new server URL in the Needle Engine Networking component to send and receive messages from there:
needle – tools for creators • @NeedleTools • @marcel_wiessler • @hybridherbst