# leystryku/leysourceengineclient architecture

> Architecture diagram of the GitHub repository leystryku/leysourceengineclient, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-04). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/leystryku/leysourceengineclient
- Repository: https://github.com/leystryku/leysourceengineclient

## Overview

LeySourceEngineClient is a small Windows Source Engine client for connecting to an OB-based game server. Its primary workflow takes server and client options, establishes a connection, exchanges connectionless and channel packets, and processes server messages and file fragments. The README documents the connection purpose; sampled code shows the main receive/send loop and message registration. Some networking and Steam details are unsampled, so those relationships are omitted or marked unverified rather than inferred as definite calls.

Main entry points: [`src/leychan.cpp`](https://github.com/leystryku/leysourceengineclient/blob/master/src/leychan.cpp) (Net channel), [`src/leysourceengineclient.cpp`](https://github.com/leystryku/leysourceengineclient/blob/master/src/leysourceengineclient.cpp) (Client runtime), [`src/datagram.cpp`](https://github.com/leystryku/leysourceengineclient/blob/master/src/datagram.cpp) (Datagram handling), [`src/netmsghandlers/svc_messages.h`](https://github.com/leystryku/leysourceengineclient/blob/master/src/netmsghandlers/svc_messages.h) (Server messages)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Client workflow"]
  node_cli["Command-line options<br/>[commandline.cpp]"]
  node_client["Client runtime"]
  node_steam["Steam integration<br/>[steam.cpp]"]
end

subgraph group_transport["Network transport"]
  node_udp["UDP networking<br/>[leynet.cpp]"]
  node_datagram["Datagram handling<br/>[datagram.cpp]"]
  node_oob["Connectionless packets<br/>[oob.cpp]"]
end

subgraph group_protocol["Source protocol"]
  node_channel["Net channel<br/>[leychan.cpp]"]
  node_nethandlers["Client messages<br/>[net_messages.h]"]
  node_svchandlers["Server messages<br/>[svc_messages.h]"]
  node_gmodhandler["GMod messages"]
  node_fragments["File fragments<br/>[datafragments.h]"]
end

subgraph group_support["Protocol support"]
  node_bitbuf["Bit buffers<br/>[buf.h]"]
  node_checksums["Packet checksums<br/>[checksum_crc.h]"]
  node_compression["Packet compression<br/>[clzss.h]"]
end

node_operator(("Client operator"))
node_server(("Game server"))

node_operator -->|"starts"| node_client
node_operator -->|"supplies options"| node_cli
node_client -->|"reads options"| node_cli
node_client -->|"opens socket"| node_udp
node_client -->|"sends datagrams"| node_datagram
node_client -->|"handles connectionless packets"| node_oob
node_client -->|"processes channel data"| node_channel
node_server -.->|"exchanges packets"| node_datagram
node_datagram -.->|"carries channel packets"| node_channel
node_channel -->|"registers handlers"| node_nethandlers
node_channel -.->|"registers handlers"| node_svchandlers
node_svchandlers -->|"includes handler"| node_gmodhandler
node_channel -->|"tracks transfers"| node_fragments
node_client -.->|"uses Steam API"| node_steam
node_channel -->|"reads and writes"| node_bitbuf
node_channel -->|"checks packets"| node_checksums
node_channel -->|"uses compression"| node_compression

click node_cli "https://github.com/leystryku/leysourceengineclient/blob/master/src/commandline.cpp"
click node_client "https://github.com/leystryku/leysourceengineclient/blob/master/src/leysourceengineclient.cpp"
click node_steam "https://github.com/leystryku/leysourceengineclient/blob/master/src/steam.cpp"
click node_udp "https://github.com/leystryku/leysourceengineclient/blob/master/src/leynet.cpp"
click node_datagram "https://github.com/leystryku/leysourceengineclient/blob/master/src/datagram.cpp"
click node_oob "https://github.com/leystryku/leysourceengineclient/blob/master/src/oob.cpp"
click node_channel "https://github.com/leystryku/leysourceengineclient/blob/master/src/leychan.cpp"
click node_nethandlers "https://github.com/leystryku/leysourceengineclient/blob/master/src/netmsghandlers/net_messages.h"
click node_svchandlers "https://github.com/leystryku/leysourceengineclient/blob/master/src/netmsghandlers/svc_messages.h"
click node_gmodhandler "https://github.com/leystryku/leysourceengineclient/blob/master/src/netmsghandlers/svc/svc_gmod_servertoclient.cpp"
click node_fragments "https://github.com/leystryku/leysourceengineclient/blob/master/src/valve/datafragments.h"
click node_bitbuf "https://github.com/leystryku/leysourceengineclient/blob/master/src/valve/buf.h"
click node_checksums "https://github.com/leystryku/leysourceengineclient/blob/master/src/valve/checksum_crc.h"
click node_compression "https://github.com/leystryku/leysourceengineclient/blob/master/src/valve/clzss.h"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_cli,node_client,node_steam,node_operator toneBlue
class node_udp,node_datagram,node_oob toneAmber
class node_channel,node_nethandlers,node_svchandlers,node_gmodhandler,node_fragments,node_server toneMint
class node_bitbuf,node_checksums,node_compression toneRose
```

## Components

### Client workflow

- [Command-line options](https://github.com/leystryku/leysourceengineclient/blob/master/src/commandline.cpp): `src/commandline.cpp`
- [Client runtime](https://github.com/leystryku/leysourceengineclient/blob/master/src/leysourceengineclient.cpp): `src/leysourceengineclient.cpp`
- [Steam integration](https://github.com/leystryku/leysourceengineclient/blob/master/src/steam.cpp): `src/steam.cpp`

### Network transport

- [UDP networking](https://github.com/leystryku/leysourceengineclient/blob/master/src/leynet.cpp): `src/leynet.cpp`
- [Datagram handling](https://github.com/leystryku/leysourceengineclient/blob/master/src/datagram.cpp): `src/datagram.cpp`
- [Connectionless packets](https://github.com/leystryku/leysourceengineclient/blob/master/src/oob.cpp): `src/oob.cpp`

### Source protocol

- [Net channel](https://github.com/leystryku/leysourceengineclient/blob/master/src/leychan.cpp): `src/leychan.cpp`
- [Client messages](https://github.com/leystryku/leysourceengineclient/blob/master/src/netmsghandlers/net_messages.h): `src/netmsghandlers/net_messages.h`
- [Server messages](https://github.com/leystryku/leysourceengineclient/blob/master/src/netmsghandlers/svc_messages.h): `src/netmsghandlers/svc_messages.h`
- [GMod messages](https://github.com/leystryku/leysourceengineclient/blob/master/src/netmsghandlers/svc/svc_gmod_servertoclient.cpp): `src/netmsghandlers/svc/svc_gmod_servertoclient.cpp`
- [File fragments](https://github.com/leystryku/leysourceengineclient/blob/master/src/valve/datafragments.h): `src/valve/datafragments.h`

### Protocol support

- [Bit buffers](https://github.com/leystryku/leysourceengineclient/blob/master/src/valve/buf.h): `src/valve/buf.h`
- [Packet checksums](https://github.com/leystryku/leysourceengineclient/blob/master/src/valve/checksum_crc.h): `src/valve/checksum_crc.h`
- [Packet compression](https://github.com/leystryku/leysourceengineclient/blob/master/src/valve/clzss.h): `src/valve/clzss.h`

### Other components

- **Client operator**
- **Game server**

## Connections

- Client operator → Client runtime: starts
- Client operator → Command-line options: supplies options
- Client runtime → Command-line options: reads options (evidence: `src/leysourceengineclient.cpp`)
- Client runtime → UDP networking: opens socket (evidence: `src/leysourceengineclient.cpp`)
- Client runtime → Datagram handling: sends datagrams (evidence: `src/leysourceengineclient.cpp`)
- Client runtime → Connectionless packets: handles connectionless packets (evidence: `src/leysourceengineclient.cpp`)
- Client runtime → Net channel: processes channel data (evidence: `src/leysourceengineclient.cpp`)
- Game server → Datagram handling: exchanges packets
- Datagram handling → Net channel: carries channel packets
- Net channel → Client messages: registers handlers (evidence: `src/leychan.cpp`)
- Net channel → Server messages: registers handlers (evidence: `src/leychan.cpp`)
- Server messages → GMod messages: includes handler (evidence: `src/netmsghandlers/svc_messages.h`)
- Net channel → File fragments: tracks transfers
- Client runtime → Steam integration: uses Steam API
- Net channel → Bit buffers: reads and writes (evidence: `src/leychan.cpp`)
- Net channel → Packet checksums: checks packets (evidence: `src/leychan.cpp`)
- Net channel → Packet compression: uses compression (evidence: `src/leychan.cpp`)
