Dark Iot
Electronic and Programming for pleasure
WebSocket GameServer
FunctionDocumentation
Why
Establish Connecton
Client Status Update
Why
A Current Sparetime project is the writing of a WebSocket 3D GameServer,
inspired from
THREE.JS .
THREE.JS works well for little Browser side 3D Projects, but I had the fear that on a larger scale the CPU performance wouldn't be enough to do it with JavaScript.
Because for each RayCast, which is used for collission detection, a lot of calculations are done for each triangle, and a WorldMesh has a lot of triangles.
So the idea was to make Raycasts as close to the MachineCode as Possible, thats why I searched and ported the Raycast or intersectTriangle Function to C++.
Since on the Serverside are not textures are required and
Wavefront OBJ files
are a simple Fileformat, I started to write a loader for them.
Establish Connecton
The client (webpage) opens a webSocket connection, without sending data.
The server response to the open connection with a connection id. Everytime the client sends data, this connection ID needs to be send.
'{"ConID":1}'
Client Status Update
The client notifys the server about the input states like:
'{"KeyDown":0,"KeyUp":0,"KeyLeft":0,"KeyRight":0,"Space":0,"ConID":1}'