<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: DDCoder23</title>
    <description>The latest articles on DEV Community by DDCoder23 (@ddcoder23).</description>
    <link>https://dev.to/ddcoder23</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4103295%2F0ca5131f-5aeb-438c-b1cb-2a1137853aa1.png</url>
      <title>DEV Community: DDCoder23</title>
      <link>https://dev.to/ddcoder23</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ddcoder23"/>
    <language>en</language>
    <item>
      <title>🦀🌐 Building the Network Architecture of an Open-Source MMORPG with Rust</title>
      <dc:creator>DDCoder23</dc:creator>
      <pubDate>Sat, 12 Sep 2026 16:34:46 +0000</pubDate>
      <link>https://dev.to/ddcoder23/building-the-network-architecture-of-an-open-source-mmorpg-with-rust-bhh</link>
      <guid>https://dev.to/ddcoder23/building-the-network-architecture-of-an-open-source-mmorpg-with-rust-bhh</guid>
      <description>&lt;h1&gt;
  
  
  🦀🌐 Building the Network Architecture of an Open-Source MMORPG with Rust
&lt;/h1&gt;

&lt;p&gt;When building a multiplayer game, one of the first systems that has to become reliable is the network layer.&lt;/p&gt;

&lt;p&gt;For &lt;strong&gt;The Last Signal Online&lt;/strong&gt;, an open-source post-apocalyptic MMORPG I'm building, the server is written in &lt;strong&gt;Rust&lt;/strong&gt; and communicates with clients through a custom TCP protocol.&lt;/p&gt;

&lt;p&gt;The current networking layer is still under development, but it already has several important components:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;a TCP server built with Tokio&lt;/li&gt;
&lt;li&gt;asynchronous client handling&lt;/li&gt;
&lt;li&gt;a custom binary packet format&lt;/li&gt;
&lt;li&gt;packet parsing and validation&lt;/li&gt;
&lt;li&gt;packet routing&lt;/li&gt;
&lt;li&gt;authentication and account management&lt;/li&gt;
&lt;li&gt;SQLite integration&lt;/li&gt;
&lt;li&gt;session management&lt;/li&gt;
&lt;li&gt;periodic ban verification&lt;/li&gt;
&lt;li&gt;structured client logging&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This article explains how the current architecture works and what I am working toward next.&lt;/p&gt;




&lt;h2&gt;
  
  
  🏗️ Current Architecture
&lt;/h2&gt;

&lt;p&gt;The networking code is organized into five main modules:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;server_rust/src/network/

├── packet.rs
├── client.rs
├── server.rs
├── handler.rs
└── parser.rs
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each module currently has a specific responsibility.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;                    ┌─────────────────────┐
                    │      TCP Client      │
                    └──────────┬──────────┘
                               │
                               │ TCP
                               ▼
                    ┌─────────────────────┐
                    │       Server        │
                    │    TcpListener      │
                    └──────────┬──────────┘
                               │
                     creates Client
                               │
                               ▼
                    ┌─────────────────────┐
                    │       Client        │
                    │  session + socket   │
                    └──────────┬──────────┘
                               │
                         receive_packet()
                               │
                               ▼
                    ┌─────────────────────┐
                    │       Packet        │
                    └──────────┬──────────┘
                               │
                               ▼
                    ┌─────────────────────┐
                    │   PacketHandler     │
                    └──────────┬──────────┘
                               │
             ┌─────────────────┼──────────────────┐
             ▼                 ▼                  ▼
          Parser            SQLite             Response
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The goal is to keep the low-level TCP handling separate from packet processing and application logic.&lt;/p&gt;




&lt;h1&gt;
  
  
  🚀 1. The TCP Server
&lt;/h1&gt;

&lt;p&gt;The entry point for incoming network connections is the &lt;code&gt;Server&lt;/code&gt; structure.&lt;/p&gt;

&lt;p&gt;It contains:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="k"&gt;pub&lt;/span&gt; &lt;span class="k"&gt;struct&lt;/span&gt; &lt;span class="n"&gt;Server&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;listener&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;TcpListener&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;database&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;DatabaseManager&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The server creates a Tokio &lt;code&gt;TcpListener&lt;/code&gt; and binds it to the configured address.&lt;/p&gt;

&lt;p&gt;Once started, it continuously waits for incoming connections:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="k"&gt;loop&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;match&lt;/span&gt; &lt;span class="k"&gt;self&lt;/span&gt;&lt;span class="py"&gt;.listener&lt;/span&gt;&lt;span class="nf"&gt;.accept&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="k"&gt;.await&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nf"&gt;Ok&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="n"&gt;stream&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;address&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="k"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="c1"&gt;// ...&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;

        &lt;span class="nf"&gt;Err&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="c1"&gt;// ...&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When a client connects, the server obtains:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;the TCP stream&lt;/li&gt;
&lt;li&gt;the client's socket address&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It then creates a new &lt;code&gt;Client&lt;/code&gt; instance.&lt;/p&gt;




&lt;h1&gt;
  
  
  ⚡ 2. One Asynchronous Task per Client
&lt;/h1&gt;

&lt;p&gt;The current implementation uses Tokio tasks to handle clients independently.&lt;/p&gt;

&lt;p&gt;When a connection is accepted:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="nn"&gt;task&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;spawn&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="k"&gt;move&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="k"&gt;mut&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nn"&gt;Client&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;new&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;stream&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;pool&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="nf"&gt;.run&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="k"&gt;.await&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This means the main listener can immediately return to accepting other connections.&lt;/p&gt;

&lt;p&gt;Conceptually:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;                    TCP Listener
                         │
          ┌──────────────┼──────────────┐
          ▼              ▼              ▼
       Client A       Client B       Client C
          │              │              │
       Tokio task     Tokio task     Tokio task
          │              │              │
       run()           run()           run()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is important for a multiplayer game because the server cannot block while waiting for a single player.&lt;/p&gt;




&lt;h1&gt;
  
  
  👤 3. The Client Session
&lt;/h1&gt;

&lt;p&gt;Each connected player is represented by a &lt;code&gt;Client&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The structure currently stores:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="k"&gt;pub&lt;/span&gt; &lt;span class="k"&gt;struct&lt;/span&gt; &lt;span class="n"&gt;Client&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;stream&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;TcpStream&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;pool&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;SqlitePool&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;session_id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;Uuid&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;client_id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;Option&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nb"&gt;i64&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;user_id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;Option&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nb"&gt;String&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;account_id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;Option&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nb"&gt;i64&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This gives the networking layer both the connection itself and some session state.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;session_id&lt;/code&gt; is generated when the &lt;code&gt;Client&lt;/code&gt; is created:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="n"&gt;session_id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nn"&gt;Uuid&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;new_v4&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This provides a unique identifier for the network session independently from the database user ID.&lt;/p&gt;

&lt;p&gt;The client can also progressively acquire information during authentication:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;TCP connection
      │
      ▼
Client created
      │
      ├── session_id
      ├── client_id = None
      ├── user_id = None
      └── account_id = None
             │
             │ login/signup
             ▼
       session becomes
       associated with
       a user
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h1&gt;
  
  
  🔄 4. The Client Event Loop
&lt;/h1&gt;

&lt;p&gt;Once a client is created, &lt;code&gt;Client::run()&lt;/code&gt; becomes responsible for the connection.&lt;/p&gt;

&lt;p&gt;The interesting part is the use of:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="nn"&gt;tokio&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nd"&gt;select!&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The client is currently waiting for two kinds of events:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;an incoming network packet&lt;/li&gt;
&lt;li&gt;a periodic ban-check timer&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Conceptually:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;                 Client::run()
                      │
                 tokio::select!
                 /            \
                /              \
       Network packet       Ban timer
             │                  │
             ▼                  ▼
      receive_packet()      get_ban_info()
             │                  │
             ▼                  ▼
      PacketHandler          BAN packet
             │                  │
             ▼                  ▼
       Response             disconnect
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This allows the connection to remain responsive while the server performs periodic session checks.&lt;/p&gt;




&lt;h1&gt;
  
  
  📦 5. The Packet Format
&lt;/h1&gt;

&lt;p&gt;The protocol currently uses a small custom binary framing format.&lt;/p&gt;

&lt;p&gt;Every packet contains:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;┌───────────────────────────┐
│ Packet size   │ 4 bytes   │
├───────────────────────────┤
│ Packet type   │ 2 bytes   │
├───────────────────────────┤
│ Payload       │ variable  │
└───────────────────────────┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The packet size is encoded as a big-endian &lt;code&gt;u32&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The packet type is encoded as a big-endian &lt;code&gt;u16&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The remaining bytes are the payload.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[ 4-byte size ]
[ 2-byte type ]
[ payload...  ]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This framing allows the receiver to know exactly how many bytes belong to the current packet before processing it.&lt;/p&gt;




&lt;h1&gt;
  
  
  🧩 6. Packet Types
&lt;/h1&gt;

&lt;p&gt;The current protocol defines several packet types:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="k"&gt;pub&lt;/span&gt; &lt;span class="k"&gt;enum&lt;/span&gt; &lt;span class="n"&gt;PacketType&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;Ping&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;Login&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;Chat&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;Move&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;Log&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;SignUp&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;LoginResponse&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;7&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;SignUpResponse&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;BAN&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;9&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The protocol therefore already covers several fundamental systems:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Packet&lt;/th&gt;
&lt;th&gt;Current purpose&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;Ping&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Connection/liveness test&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;Login&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Authentication&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;Chat&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Chat messages&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;Move&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Player movement&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;Log&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Client-side logging&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;SignUp&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Account creation&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;LoginResponse&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Server login response&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;SignUpResponse&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Server signup response&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;BAN&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Server-side ban notification&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The conversion between the numeric protocol value and the Rust enum is handled by &lt;code&gt;PacketType::from_u16()&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Unknown packet types are rejected.&lt;/p&gt;




&lt;h1&gt;
  
  
  🛡️ 7. Packet Size Validation
&lt;/h1&gt;

&lt;p&gt;The server currently defines:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="k"&gt;pub&lt;/span&gt; &lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="n"&gt;MAX_PACKET_SIZE&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;usize&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;1024&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;1024&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Both sending and receiving enforce this maximum.&lt;/p&gt;

&lt;p&gt;A packet smaller than the two bytes required for the packet type is also rejected.&lt;/p&gt;

&lt;p&gt;This gives the current framing layer some basic protection against malformed or unexpectedly large frames.&lt;/p&gt;

&lt;p&gt;The receiver follows this process:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Read 4 bytes
    │
    ▼
Decode packet size
    │
    ├── size &amp;lt; 2 ───────► reject
    │
    ├── size &amp;gt; 10 MiB ──► reject
    │
    ▼
Read exactly `size` bytes
    │
    ▼
Read packet type
    │
    ├── unknown ────────► reject
    │
    ▼
Extract payload
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The use of &lt;code&gt;read_exact()&lt;/code&gt; is particularly useful here because the server explicitly requests the number of bytes required for the current frame.&lt;/p&gt;




&lt;h1&gt;
  
  
  🔍 8. Parsing Login and Signup Payloads
&lt;/h1&gt;

&lt;p&gt;Packets provide the outer framing.&lt;/p&gt;

&lt;p&gt;The parser then interprets the payload for specific packet types.&lt;/p&gt;

&lt;p&gt;For login and signup, the current payload format is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;┌────────────────────────┐
│ Email length │ 2 bytes │
├────────────────────────┤
│ Email        │ variable│
├────────────────────────┤
│ Password len │ 2 bytes │
├────────────────────────┤
│ Password     │ variable│
└────────────────────────┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Both lengths are stored as big-endian &lt;code&gt;u16&lt;/code&gt; values.&lt;/p&gt;

&lt;p&gt;The parser performs several validation steps:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;checks that the length field exists&lt;/li&gt;
&lt;li&gt;checks that the declared number of bytes exists&lt;/li&gt;
&lt;li&gt;converts the data from UTF-8&lt;/li&gt;
&lt;li&gt;returns an error when the payload is malformed&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For example, an incomplete email is rejected before the server attempts to interpret it.&lt;/p&gt;

&lt;p&gt;This keeps payload parsing separate from packet routing.&lt;/p&gt;




&lt;h1&gt;
  
  
  🧠 9. Packet Routing
&lt;/h1&gt;

&lt;p&gt;Once a packet has been decoded, it is passed to:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="nn"&gt;PacketHandler&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;handle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;...&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The handler matches on the packet type.&lt;/p&gt;

&lt;p&gt;Conceptually:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Packet
  │
  ▼
match packet.packet_type
  │
  ├── Ping
  ├── Login
  ├── SignUp
  ├── Chat
  ├── Move
  ├── Log
  ├── BAN
  └── Responses
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is currently the main bridge between the networking layer and the rest of the server.&lt;/p&gt;




&lt;h1&gt;
  
  
  🏓 10. Ping / Pong
&lt;/h1&gt;

&lt;p&gt;The simplest packet currently implemented is &lt;code&gt;Ping&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;When the server receives it, the handler creates another packet:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="nn"&gt;Packet&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;new&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="nn"&gt;PacketType&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="n"&gt;Ping&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s"&gt;b"PONG"&lt;/span&gt;&lt;span class="nf"&gt;.to_vec&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The response is then sent back through the same TCP connection.&lt;/p&gt;

&lt;p&gt;So the current flow is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Client
  │
  │ PING
  ▼
Server
  │
  │ PacketHandler
  ▼
  PONG
  │
  ▼
Client
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This provides a simple way to test basic connectivity.&lt;/p&gt;




&lt;h1&gt;
  
  
  🔐 11. Authentication
&lt;/h1&gt;

&lt;p&gt;The networking layer is already connected to the authentication system.&lt;/p&gt;

&lt;p&gt;For a &lt;code&gt;LOGIN&lt;/code&gt; packet, the handler:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;parses the payload&lt;/li&gt;
&lt;li&gt;searches for the user in SQLite&lt;/li&gt;
&lt;li&gt;checks permanent and temporary bans&lt;/li&gt;
&lt;li&gt;verifies the password hash&lt;/li&gt;
&lt;li&gt;tracks failed login attempts&lt;/li&gt;
&lt;li&gt;applies the temporary ban mechanism when necessary&lt;/li&gt;
&lt;li&gt;checks whether the account is already connected&lt;/li&gt;
&lt;li&gt;marks the user as connected&lt;/li&gt;
&lt;li&gt;associates the authenticated user with the &lt;code&gt;Client&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;returns a login response&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The password verification itself is delegated to the project's password utility.&lt;/p&gt;

&lt;p&gt;The handler therefore acts as the current integration point between:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Network protocol
       │
       ▼
Login parser
       │
       ▼
Authentication
       │
       ├── SQLite
       ├── password verification
       ├── ban system
       └── session state
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h1&gt;
  
  
  🚫 12. Failed Login Attempts and Temporary Bans
&lt;/h1&gt;

&lt;p&gt;The current login system also keeps track of failed attempts.&lt;/p&gt;

&lt;p&gt;After three failed attempts, the server can create or extend a temporary ban.&lt;/p&gt;

&lt;p&gt;There is also a &lt;code&gt;banssursis&lt;/code&gt; mechanism in the current database logic that can modify the duration of the resulting ban.&lt;/p&gt;

&lt;p&gt;This means authentication is not simply:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;password correct → login
password wrong   → reject
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There is already a larger state machine:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Login attempt
     │
     ▼
Find user
     │
     ├── not found ─────────► reject
     │
     ▼
Check bans
     │
     ├── banned ────────────► reject
     │
     ▼
Verify password
     │
     ├── incorrect
     │      │
     │      ▼
     │   increment attempts
     │      │
     │      ├── &amp;lt; 3 ───────► reject
     │      │
     │      └── ≥ 3 ───────► temporary ban
     │
     ▼
Check connected status
     │
     ├── already connected ─► reject
     │
     ▼
Mark CONNECTED
     │
     ▼
Associate user with Client
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is one of the areas where the network layer is already interacting heavily with persistent server state.&lt;/p&gt;




&lt;h1&gt;
  
  
  📝 13. Client Logging
&lt;/h1&gt;

&lt;p&gt;The protocol also contains a &lt;code&gt;Log&lt;/code&gt; packet.&lt;/p&gt;

&lt;p&gt;The client can send structured logging information containing:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="k"&gt;pub&lt;/span&gt; &lt;span class="k"&gt;struct&lt;/span&gt; &lt;span class="n"&gt;ClientLog&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;pub&lt;/span&gt; &lt;span class="n"&gt;level&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;LogLevel&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="k"&gt;pub&lt;/span&gt; &lt;span class="n"&gt;module&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;String&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="k"&gt;pub&lt;/span&gt; &lt;span class="n"&gt;file&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;String&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="k"&gt;pub&lt;/span&gt; &lt;span class="n"&gt;line&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;u32&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="k"&gt;pub&lt;/span&gt; &lt;span class="n"&gt;message&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;String&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The server deserializes this data using &lt;code&gt;serde_json&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Depending on the received level, it forwards the message to the server's logging system.&lt;/p&gt;

&lt;p&gt;Supported levels currently include:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;TRACE
DEBUG
INFO
WARNING
ERROR
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This gives the client a mechanism for reporting structured diagnostic information to the server.&lt;/p&gt;




&lt;h1&gt;
  
  
  💬 14. Chat and Movement
&lt;/h1&gt;

&lt;p&gt;The protocol already defines &lt;code&gt;Chat&lt;/code&gt; and &lt;code&gt;Move&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;At the current stage, their handling is intentionally simple.&lt;/p&gt;

&lt;p&gt;For chat:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="nn"&gt;Packet&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;new&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="nn"&gt;PacketType&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="n"&gt;Chat&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;packet&lt;/span&gt;&lt;span class="py"&gt;.payload&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The server currently logs the received message and sends the payload back.&lt;/p&gt;

&lt;p&gt;Movement currently follows a similar basic path.&lt;/p&gt;

&lt;p&gt;This is important because these packet types are part of the current protocol, but their gameplay functionality is &lt;strong&gt;not yet a complete MMORPG networking system&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The architecture is being built before the full gameplay layer is implemented.&lt;/p&gt;




&lt;h1&gt;
  
  
  ⛔ 15. Server-Only Responses
&lt;/h1&gt;

&lt;p&gt;The handler also explicitly rejects packets that should only originate from the server.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Client → LoginResponse
Client → SignUpResponse
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;are considered invalid directions.&lt;/p&gt;

&lt;p&gt;The server logs the situation and does not generate a response.&lt;/p&gt;

&lt;p&gt;This establishes an important concept for the protocol:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Not every packet type is valid in both directions.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;As the protocol grows, this distinction will become increasingly important.&lt;/p&gt;




&lt;h1&gt;
  
  
  🔨 16. Signup
&lt;/h1&gt;

&lt;p&gt;Account creation follows a similar path to login:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SIGN_UP packet
      │
      ▼
parse_signup_payload()
      │
      ▼
hash password
      │
      ▼
generate UUID
      │
      ▼
INSERT INTO users
      │
      ▼
associate user with Client
      │
      ▼
SIGN_UP response
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The password is hashed before being stored.&lt;/p&gt;

&lt;p&gt;The database also handles duplicate email detection.&lt;/p&gt;




&lt;h1&gt;
  
  
  🔌 17. Session Disconnection
&lt;/h1&gt;

&lt;p&gt;When a client disconnects, the &lt;code&gt;Client&lt;/code&gt; performs cleanup.&lt;/p&gt;

&lt;p&gt;If the session has an authenticated user, the server updates the database:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CONNECTED
    │
    │ disconnect
    ▼
DISCONNECTED
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The socket can then be shut down cleanly.&lt;/p&gt;

&lt;p&gt;This means the network session and persistent user state are connected.&lt;/p&gt;




&lt;h1&gt;
  
  
  ⏱️ 18. Periodic Ban Checking
&lt;/h1&gt;

&lt;p&gt;One interesting part of the current architecture is that ban checking does not only happen during login.&lt;/p&gt;

&lt;p&gt;The client starts a Tokio interval:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="nf"&gt;interval&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nn"&gt;Duration&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;from_secs&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once a player is authenticated, the server periodically checks whether a ban has become active.&lt;/p&gt;

&lt;p&gt;If a ban is detected:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Database
    │
    ▼
Ban detected
    │
    ▼
Create BAN packet
    │
    ▼
Send to client
    │
    ▼
Disconnect
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This means an already-connected player can be removed from the server if their account becomes banned while their session is active.&lt;/p&gt;




&lt;h1&gt;
  
  
  🔐 19. What About Network Security?
&lt;/h1&gt;

&lt;p&gt;The current networking code is intentionally still an evolving part of the project.&lt;/p&gt;

&lt;p&gt;The code described in this article provides:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;packet framing&lt;/li&gt;
&lt;li&gt;packet size limits&lt;/li&gt;
&lt;li&gt;packet type validation&lt;/li&gt;
&lt;li&gt;payload validation&lt;/li&gt;
&lt;li&gt;authentication&lt;/li&gt;
&lt;li&gt;password hashing&lt;/li&gt;
&lt;li&gt;ban handling&lt;/li&gt;
&lt;li&gt;session tracking&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;However, this should &lt;strong&gt;not&lt;/strong&gt; be interpreted as a finished secure production protocol.&lt;/p&gt;

&lt;p&gt;For example, the networking files shown here implement TCP framing, but they do not themselves provide transport encryption such as TLS.&lt;/p&gt;

&lt;p&gt;The project also has experimental cryptography work elsewhere, but that should not be confused with the packet framing layer described here.&lt;/p&gt;

&lt;p&gt;Security is an ongoing area of development and review.&lt;/p&gt;




&lt;h1&gt;
  
  
  🧪 20. What I Want to Improve
&lt;/h1&gt;

&lt;p&gt;The current architecture is a foundation rather than the final networking system.&lt;/p&gt;

&lt;p&gt;Some of the areas I want to develop further include:&lt;/p&gt;

&lt;h3&gt;
  
  
  Better protocol validation
&lt;/h3&gt;

&lt;p&gt;More malformed and invalid packet tests are needed.&lt;/p&gt;

&lt;p&gt;Examples include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;invalid packet sizes&lt;/li&gt;
&lt;li&gt;unknown packet types&lt;/li&gt;
&lt;li&gt;truncated payloads&lt;/li&gt;
&lt;li&gt;invalid UTF-8&lt;/li&gt;
&lt;li&gt;invalid field lengths&lt;/li&gt;
&lt;li&gt;unexpected packet directions&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Network integration tests
&lt;/h3&gt;

&lt;p&gt;I want to test the complete path:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Client
  ↓
TCP
  ↓
Server
  ↓
Parser
  ↓
Handler
  ↓
Database
  ↓
Response
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;rather than testing each component only in isolation.&lt;/p&gt;

&lt;h3&gt;
  
  
  Better packet abstractions
&lt;/h3&gt;

&lt;p&gt;As the game grows, the number of packet types will increase significantly.&lt;/p&gt;

&lt;p&gt;The protocol therefore needs to remain easy to extend without turning the handler into an unmaintainable collection of special cases.&lt;/p&gt;

&lt;h3&gt;
  
  
  Gameplay networking
&lt;/h3&gt;

&lt;p&gt;Movement and chat are currently basic.&lt;/p&gt;

&lt;p&gt;The future network layer will need to support much more complex game state:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;player movement&lt;/li&gt;
&lt;li&gt;world state&lt;/li&gt;
&lt;li&gt;combat&lt;/li&gt;
&lt;li&gt;inventories&lt;/li&gt;
&lt;li&gt;NPCs&lt;/li&gt;
&lt;li&gt;interactions&lt;/li&gt;
&lt;li&gt;guilds&lt;/li&gt;
&lt;li&gt;territories&lt;/li&gt;
&lt;li&gt;trading&lt;/li&gt;
&lt;li&gt;persistent world events&lt;/li&gt;
&lt;/ul&gt;




&lt;h1&gt;
  
  
  🗺️ The Bigger Picture
&lt;/h1&gt;

&lt;p&gt;The current architecture can be summarized as:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;                         THE LAST SIGNAL
                         NETWORK LAYER

                              TCP
                               │
                               ▼
                    ┌────────────────────┐
                    │      Server        │
                    │   TcpListener      │
                    └─────────┬──────────┘
                              │
                    ┌─────────┴──────────┐
                    │                    │
                    ▼                    ▼
                Client A             Client B
                    │                    │
                    ▼                    ▼
              receive_packet()    receive_packet()
                    │                    │
                    └─────────┬──────────┘
                              ▼
                       PacketHandler
                              │
          ┌──────────┬────────┼────────┬──────────┐
          ▼          ▼        ▼        ▼          ▼
        Login      Signup    Chat     Move       Log
          │          │
          ▼          ▼
       SQLite     SQLite
          │
          ▼
     Session state
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The architecture is deliberately being built in layers:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;TCP transport
     ↓
Packet framing
     ↓
Payload parsing
     ↓
Packet routing
     ↓
Authentication / database
     ↓
Gameplay systems
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This gives the project a foundation on which the larger MMORPG systems can eventually be built.&lt;/p&gt;




&lt;h1&gt;
  
  
  🚀 What's Next?
&lt;/h1&gt;

&lt;p&gt;The network layer is one of the areas I expect to evolve substantially as The Last Signal Online moves from prototype infrastructure toward actual multiplayer gameplay.&lt;/p&gt;

&lt;p&gt;The next major challenges are not simply "making packets work".&lt;/p&gt;

&lt;p&gt;They are about making the protocol:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;reliable&lt;/li&gt;
&lt;li&gt;testable&lt;/li&gt;
&lt;li&gt;extensible&lt;/li&gt;
&lt;li&gt;secure&lt;/li&gt;
&lt;li&gt;efficient&lt;/li&gt;
&lt;li&gt;easy for contributors to understand&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And that is exactly where open-source development becomes interesting.&lt;/p&gt;




&lt;h1&gt;
  
  
  🤝 Want to Contribute?
&lt;/h1&gt;

&lt;p&gt;The Last Signal Online is an open-source project, and there are several ways to contribute.&lt;/p&gt;

&lt;p&gt;You don't need to work on gameplay to help.&lt;/p&gt;

&lt;p&gt;Current areas include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;🦀 Rust server development&lt;/li&gt;
&lt;li&gt;🌐 network protocol development&lt;/li&gt;
&lt;li&gt;🧪 network testing&lt;/li&gt;
&lt;li&gt;🐍 Python client development&lt;/li&gt;
&lt;li&gt;🔐 security and cryptography review&lt;/li&gt;
&lt;li&gt;⚙️ CI/CD&lt;/li&gt;
&lt;li&gt;📚 documentation&lt;/li&gt;
&lt;li&gt;🌍 translation&lt;/li&gt;
&lt;li&gt;🎮 game design&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you're interested in Rust networking, multiplayer architecture, Python clients, testing, or open-source game development, there are already areas where you can get involved.&lt;/p&gt;

&lt;p&gt;👉 &lt;strong&gt;&lt;a href="https://github.com/DDCoder23/The-last-signal-/issues/97" rel="noopener noreferrer"&gt;👋 New Contributor? Start Here!&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You can also explore the project's open issues and choose a problem that matches your interests and experience.&lt;/p&gt;




&lt;h1&gt;
  
  
  🦀 About The Last Signal Online
&lt;/h1&gt;

&lt;p&gt;&lt;strong&gt;The Last Signal Online&lt;/strong&gt; is an open-source post-apocalyptic persistent-world MMORPG built with Rust and Python.&lt;/p&gt;

&lt;p&gt;The goal is to create a multiplayer world combining:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;exploration&lt;/li&gt;
&lt;li&gt;survival&lt;/li&gt;
&lt;li&gt;combat&lt;/li&gt;
&lt;li&gt;player interaction&lt;/li&gt;
&lt;li&gt;economy&lt;/li&gt;
&lt;li&gt;crafting&lt;/li&gt;
&lt;li&gt;factions and territories&lt;/li&gt;
&lt;li&gt;persistent world systems&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The project is still under development, which means the architecture is evolving alongside the game itself.&lt;/p&gt;

&lt;p&gt;That also means there are plenty of interesting problems left to solve.&lt;/p&gt;

&lt;p&gt;👉 &lt;strong&gt;&lt;a href="https://github.com/DDCoder23/The-last-signal-" rel="noopener noreferrer"&gt;Explore the project on GitHub&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  💬 Final Thoughts
&lt;/h2&gt;

&lt;p&gt;Building the network layer of an MMORPG is a very different problem from building a simple client/server application.&lt;/p&gt;

&lt;p&gt;A &lt;code&gt;Ping&lt;/code&gt; packet is easy.&lt;/p&gt;

&lt;p&gt;Building a protocol that can eventually carry an entire persistent multiplayer world is much harder.&lt;/p&gt;

&lt;p&gt;That's the challenge I'm working on with The Last Signal Online.&lt;/p&gt;

&lt;p&gt;And I'm building it openly, one system at a time.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;If Rust, networking, Python, game development, or open source interests you, feel free to take a look at the project. 🦀🐍🌐&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>python</category>
      <category>crypto</category>
      <category>testing</category>
    </item>
    <item>
      <title>I'm Building an Open-Source MMORPG with Rust &amp; Python — Join the Project</title>
      <dc:creator>DDCoder23</dc:creator>
      <pubDate>Tue, 01 Sep 2026 05:04:14 +0000</pubDate>
      <link>https://dev.to/ddcoder23/im-building-an-open-source-mmorpg-with-rust-python-join-the-project-2lp0</link>
      <guid>https://dev.to/ddcoder23/im-building-an-open-source-mmorpg-with-rust-python-join-the-project-2lp0</guid>
      <description>&lt;h1&gt;
  
  
  I'm Building an Open-Source MMORPG in Rust and Python — Looking for Contributors
&lt;/h1&gt;

&lt;p&gt;Hi everyone! 👋&lt;/p&gt;

&lt;p&gt;I'm currently working on &lt;strong&gt;The Last Signal&lt;/strong&gt;, an open-source post-apocalyptic MMORPG project.&lt;/p&gt;

&lt;p&gt;The project is built around &lt;strong&gt;Rust and Python&lt;/strong&gt;, with a strong focus on networking, server architecture, testing, and eventually building a persistent multiplayer world.&lt;/p&gt;

&lt;p&gt;The project is still in development, so there are plenty of things to explore, improve, and build.&lt;/p&gt;

&lt;h2&gt;
  
  
  🎮 What is The Last Signal?
&lt;/h2&gt;

&lt;p&gt;The goal is to create a multiplayer post-apocalyptic world where players can explore, interact, fight, trade, and build their own stories.&lt;/p&gt;

&lt;p&gt;Rather than trying to build everything at once, I'm currently focusing on developing the foundations of the project: communication between the client and server, packet handling, testing, CI, and the overall architecture.&lt;/p&gt;

&lt;h2&gt;
  
  
  🛠️ Current technologies
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;🦀 &lt;strong&gt;Rust&lt;/strong&gt; — server and network-related components&lt;/li&gt;
&lt;li&gt;🐍 &lt;strong&gt;Python&lt;/strong&gt; — client and tools&lt;/li&gt;
&lt;li&gt;🌐 Client/server networking&lt;/li&gt;
&lt;li&gt;📦 Custom network packet system&lt;/li&gt;
&lt;li&gt;🧪 Automated testing&lt;/li&gt;
&lt;li&gt;⚙️ GitHub Actions / CI&lt;/li&gt;
&lt;li&gt;🗄️ Database components&lt;/li&gt;
&lt;li&gt;🔐 Experimental cryptography — currently at a very early stage&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  🌐 The networking side
&lt;/h2&gt;

&lt;p&gt;One of the current technical focuses is the communication between the Python client and the Rust server.&lt;/p&gt;

&lt;p&gt;The project has its own packet system, with different packet types used for communication between the two sides.&lt;/p&gt;

&lt;p&gt;I'm currently working on things such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;packet creation&lt;/li&gt;
&lt;li&gt;serialization and deserialization&lt;/li&gt;
&lt;li&gt;handling invalid data&lt;/li&gt;
&lt;li&gt;network error handling&lt;/li&gt;
&lt;li&gt;testing the protocol&lt;/li&gt;
&lt;li&gt;keeping the client and server implementations consistent&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is one of the areas where Rust contributors could have a direct impact on the project.&lt;/p&gt;

&lt;h2&gt;
  
  
  🔐 Cryptography is only at the beginning
&lt;/h2&gt;

&lt;p&gt;The cryptography side of the project is &lt;strong&gt;very experimental and still at an early stage&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;I'm experimenting with ideas and exploring how a cryptographic system could fit into the project.&lt;/p&gt;

&lt;p&gt;At this point, it is &lt;strong&gt;not presented as production-ready or secure cryptography&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;I'm actually looking for people who can challenge the design, identify weaknesses and assumptions, and help determine which approaches are worth exploring further.&lt;/p&gt;

&lt;p&gt;Someone interested in cryptography, cryptanalysis, or security would be very welcome here.&lt;/p&gt;

&lt;h2&gt;
  
  
  🤝 I'm looking for contributors
&lt;/h2&gt;

&lt;p&gt;I'm currently looking for people interested in contributing to an open-source project.&lt;/p&gt;

&lt;h3&gt;
  
  
  🦀 Rust developers
&lt;/h3&gt;

&lt;p&gt;Help with areas such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;networking&lt;/li&gt;
&lt;li&gt;packet handling&lt;/li&gt;
&lt;li&gt;server development&lt;/li&gt;
&lt;li&gt;testing&lt;/li&gt;
&lt;li&gt;error handling&lt;/li&gt;
&lt;li&gt;architecture&lt;/li&gt;
&lt;li&gt;performance&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  🐍 Python developers
&lt;/h3&gt;

&lt;p&gt;Help with:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;client development&lt;/li&gt;
&lt;li&gt;testing&lt;/li&gt;
&lt;li&gt;tools&lt;/li&gt;
&lt;li&gt;automation&lt;/li&gt;
&lt;li&gt;communication with the Rust server&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  🔐 Security / cryptography contributors
&lt;/h3&gt;

&lt;p&gt;The cryptography work is still at the beginning.&lt;/p&gt;

&lt;p&gt;Possible contributions include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;reviewing the experimental design&lt;/li&gt;
&lt;li&gt;identifying security assumptions&lt;/li&gt;
&lt;li&gt;finding potential weaknesses&lt;/li&gt;
&lt;li&gt;researching alternative approaches&lt;/li&gt;
&lt;li&gt;designing security tests&lt;/li&gt;
&lt;li&gt;discussing the boundary between experimentation and real-world cryptography&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You don't need to immediately write cryptographic code. &lt;strong&gt;A good technical analysis can already be a valuable contribution.&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  📚 Documentation contributors
&lt;/h3&gt;

&lt;p&gt;Help make the project easier for new developers to understand:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;architecture documentation&lt;/li&gt;
&lt;li&gt;network protocol documentation&lt;/li&gt;
&lt;li&gt;developer guides&lt;/li&gt;
&lt;li&gt;English documentation&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  ⚙️ CI/CD contributors
&lt;/h3&gt;

&lt;p&gt;The project also has GitHub Actions workflows that can be improved and maintained.&lt;/p&gt;

&lt;p&gt;Contributions involving:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;testing&lt;/li&gt;
&lt;li&gt;build workflows&lt;/li&gt;
&lt;li&gt;automation&lt;/li&gt;
&lt;li&gt;reliability&lt;/li&gt;
&lt;li&gt;performance&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;are welcome.&lt;/p&gt;

&lt;h2&gt;
  
  
  🧪 Where can you start?
&lt;/h2&gt;

&lt;p&gt;I've created several GitHub Issues specifically designed as entry points for contributors.&lt;/p&gt;

&lt;p&gt;Current areas include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;🦀 Rust network protocol testing&lt;/li&gt;
&lt;li&gt;🐍 Python client testing&lt;/li&gt;
&lt;li&gt;📚 Client/server protocol documentation&lt;/li&gt;
&lt;li&gt;🔐 Cryptographic design review&lt;/li&gt;
&lt;li&gt;⚙️ CI/CD improvements&lt;/li&gt;
&lt;li&gt;🌍 English documentation&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You don't have to understand the entire project before contributing.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Small contributions are welcome.&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  🌱 You don't have to be an expert
&lt;/h2&gt;

&lt;p&gt;If you're learning Rust or Python and want experience working on a real open-source project, you're welcome to contribute.&lt;/p&gt;

&lt;p&gt;I'm particularly interested in people who enjoy:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;learning through real projects&lt;/li&gt;
&lt;li&gt;experimenting with technical ideas&lt;/li&gt;
&lt;li&gt;solving difficult problems&lt;/li&gt;
&lt;li&gt;discussing architecture&lt;/li&gt;
&lt;li&gt;reviewing and improving existing code&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can contribute by writing code, testing, documenting, reviewing, or simply providing constructive technical feedback.&lt;/p&gt;

&lt;h2&gt;
  
  
  🧠 Technical feedback is welcome
&lt;/h2&gt;

&lt;p&gt;The project is still young, so I'm not attached to every current implementation.&lt;/p&gt;

&lt;p&gt;If you see a design that could be improved, &lt;strong&gt;I'd rather hear a well-reasoned criticism than have a bad design remain in the project&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The goal is to build something better through collaboration and discussion.&lt;/p&gt;

&lt;h2&gt;
  
  
  🔗 Project
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;GitHub:&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://github.com/DDCoder23/The-last-signal-" rel="noopener noreferrer"&gt;https://github.com/DDCoder23/The-last-signal-&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The repository contains the source code, documentation, and open Issues.&lt;/p&gt;

&lt;p&gt;If the project interests you, take a look at the repository and feel free to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;open an Issue&lt;/li&gt;
&lt;li&gt;comment on an existing Issue&lt;/li&gt;
&lt;li&gt;suggest an improvement&lt;/li&gt;
&lt;li&gt;submit a Pull Request&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I'm looking forward to meeting people who want to learn, experiment, and build something together. 🦀🐍🚀&lt;/p&gt;

&lt;p&gt;Thanks for reading!&lt;/p&gt;

</description>
      <category>python</category>
      <category>crypto</category>
      <category>database</category>
      <category>rust</category>
    </item>
  </channel>
</rss>
