Skip to content

Net Overview

Jirka Dell'Oro-Friedl edited this page Sep 9, 2022 · 10 revisions

Technology

In order to play a game over the network, network connections must be established and data sent over these. FUDGE implements two types of connections for this, Websocket and WebRTC.

Websocket

is based on the TCP-Protocol, transmission is slower but a lot of care is taken to ensure the delivery of data without losses and in the right order. Websocket connection can only be established between a client and a server.

WebRTC

on the other hand is based on UDP, which provides much faster data transport, but data may be lost or received in a wrong order. Modern browsers support both protocols, so FUDGE can use them. WebRTC connection can only be established between clients, not with the server.

Topology

1. Websocket to server only

This is the minimal setup. Each client establishes a websocket connection to the server. Messages can then travel from each client to the server, and from the server to each client. The server also routes messages from on client to a specific other client or broadcasts that message to all.

2. Websocket to server and WebRTC mesh

In addition to 1. The server acts as so called signalling server and manages the establishment of WebRTC connections between the clients. In a mesh, each client is connected to each other client, so the number of connections increases exponentially with the number of clients.

alt

3. Server hosting application specific information

The server can be extended to host application specific information and do calculations that the clients then don't need to. This way the server has reliable data for all clients and code is not public.

4. Websocket to server and WebRTC to client host

A client can also serve as a host. This way, logic specific to the host can be tied closer to game logic and additional programming may be reduced. A clients request to the host by Websockets travels via the server and the answer too, so there may be quite some lag. For fast paced games, the client host should connect to the other clients via WebRTC. Since there is only one WebRTC connection for each client besides the host, the number of connections increases linearly.

Clone this wiki locally