Prettier
This commit is contained in:
@@ -12,11 +12,11 @@
|
||||
|
||||
## Connection Endpoints
|
||||
|
||||
| Protocol | Endpoint |
|
||||
|----------|----------|
|
||||
| TCP | `chat.3t.network:10009` |
|
||||
| Protocol | Endpoint |
|
||||
| --------------- | --------------------------------- |
|
||||
| TCP | `chat.3t.network:10009` |
|
||||
| WebSocket (TLS) | `wss://chat.3t.network:443/BENNC` |
|
||||
| WebSocket | `ws://chat.3t.network:80/BENNC` |
|
||||
| WebSocket | `ws://chat.3t.network:80/BENNC` |
|
||||
|
||||
## Core Requirements
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
## Message Structure
|
||||
|
||||
**Client → Server:**
|
||||
|
||||
```
|
||||
┌─────────────┬─────────────┬─────────────────────────┐
|
||||
│ Message Type│ Length │ Data │
|
||||
@@ -38,6 +39,7 @@
|
||||
```
|
||||
|
||||
**Server → Client:**
|
||||
|
||||
```
|
||||
┌─────────────┬─────────────┬─────────────┬─────────────────────┐
|
||||
│ Message Type│ Sender ID │ Length │ Data │
|
||||
@@ -45,7 +47,7 @@
|
||||
└─────────────┴─────────────┴─────────────┴─────────────────────┘
|
||||
```
|
||||
|
||||
*Sender ID is randomly generated per connection to identify message source.*
|
||||
_Sender ID is randomly generated per connection to identify message source._
|
||||
|
||||
## Encryption Implementation
|
||||
|
||||
@@ -67,22 +69,23 @@
|
||||
|
||||
## Message Types Reference
|
||||
|
||||
| ID | Name | Subscribable | Encrypted | Compressed | Purpose |
|
||||
|----|------|--------------|-----------|------------|---------|
|
||||
| 0x0000 | Subscribe | ❌ | ❌ | ❌ | Subscribe to message type |
|
||||
| 0x0001 | Basic Message | ✅ | ✅ | ❌ | Chat messages |
|
||||
| 0x0002 | Request User Data | ✅ | ✅ | ❌ | Request user info |
|
||||
| 0x0003 | User Data Response | ✅ | ✅ | ❌ | Respond with user info |
|
||||
| 0x0005 | Keepalive | ❌ | ❌ | ❌ | Prevent connection timeout |
|
||||
| 0x0006 | Advanced Text | ✅ | ✅ | ✅ | Long/rich text messages |
|
||||
| 0x0007 | Edit Advanced Text | ✅ | ✅ | ✅ | Edit/delete advanced text |
|
||||
| 0xFFFF | Unsubscribe | ❌ | ❌ | ❌ | Unsubscribe from message type |
|
||||
| ID | Name | Subscribable | Encrypted | Compressed | Purpose |
|
||||
| ------ | ------------------ | ------------ | --------- | ---------- | ----------------------------- |
|
||||
| 0x0000 | Subscribe | ❌ | ❌ | ❌ | Subscribe to message type |
|
||||
| 0x0001 | Basic Message | ✅ | ✅ | ❌ | Chat messages |
|
||||
| 0x0002 | Request User Data | ✅ | ✅ | ❌ | Request user info |
|
||||
| 0x0003 | User Data Response | ✅ | ✅ | ❌ | Respond with user info |
|
||||
| 0x0005 | Keepalive | ❌ | ❌ | ❌ | Prevent connection timeout |
|
||||
| 0x0006 | Advanced Text | ✅ | ✅ | ✅ | Long/rich text messages |
|
||||
| 0x0007 | Edit Advanced Text | ✅ | ✅ | ✅ | Edit/delete advanced text |
|
||||
| 0xFFFF | Unsubscribe | ❌ | ❌ | ❌ | Unsubscribe from message type |
|
||||
|
||||
---
|
||||
|
||||
## Message Type Specifications
|
||||
|
||||
### Subscribe (0x0000)
|
||||
|
||||
Subscribe to receive messages of specified type. Must resubscribe after disconnect.
|
||||
|
||||
**Data:** Message type to subscribe to (2 bytes, big-endian)
|
||||
@@ -90,6 +93,7 @@ Subscribe to receive messages of specified type. Must resubscribe after disconne
|
||||
---
|
||||
|
||||
### Basic Message (0x0001)
|
||||
|
||||
UTF-8 chat messages. 16-byte nonce + encrypted data ≤ 1000 bytes total.
|
||||
|
||||
**Data:** Encrypted UTF-8 string
|
||||
@@ -97,9 +101,11 @@ UTF-8 chat messages. 16-byte nonce + encrypted data ≤ 1000 bytes total.
|
||||
---
|
||||
|
||||
### Request User Data (0x0002)
|
||||
|
||||
Request user information from all users. Clients should respond with User Data Response (0x0003).
|
||||
|
||||
**Data Structure:**
|
||||
|
||||
- Username length (2 bytes, big-endian)
|
||||
- Username (up to 32 bytes, UTF-8)
|
||||
- Color RGB (3 bytes: R, G, B values)
|
||||
@@ -109,9 +115,11 @@ Request user information from all users. Clients should respond with User Data R
|
||||
---
|
||||
|
||||
### User Data Response (0x0003)
|
||||
|
||||
Send user information in response to Request User Data (0x0002).
|
||||
|
||||
**Data Structure:** Same as Request User Data
|
||||
|
||||
- Username length (2 bytes, big-endian)
|
||||
- Username (up to 32 bytes, UTF-8)
|
||||
- Color RGB (3 bytes: R, G, B values)
|
||||
@@ -121,6 +129,7 @@ Send user information in response to Request User Data (0x0002).
|
||||
---
|
||||
|
||||
### Keepalive (0x0005)
|
||||
|
||||
Prevent connection timeout when idle. Send every 30 seconds when no other traffic. Not forwarded to other clients and cannot be subscribed to.
|
||||
|
||||
**Data:** None - empty message
|
||||
@@ -128,6 +137,7 @@ Prevent connection timeout when idle. Send every 30 seconds when no other traffi
|
||||
---
|
||||
|
||||
### Unsubscribe (0xFFFF)
|
||||
|
||||
Stop receiving messages of specified type.
|
||||
|
||||
**Data:** Message type to unsubscribe from (2 bytes, big-endian)
|
||||
@@ -135,9 +145,11 @@ Stop receiving messages of specified type.
|
||||
---
|
||||
|
||||
### Advanced Text (0x0006)
|
||||
|
||||
Multi-packet messages for long text with markdown formatting and ZSTD compression.
|
||||
|
||||
**Implementation Notes:**
|
||||
|
||||
- Text is compressed **before** splitting into packets
|
||||
- Header is not compressed
|
||||
- Packets may arrive out of order - use packet numbers to reconstruct
|
||||
@@ -145,12 +157,14 @@ Multi-packet messages for long text with markdown formatting and ZSTD compressio
|
||||
- Warn users before displaying very large messages
|
||||
|
||||
**Data Structure:**
|
||||
|
||||
- Message ID (4 bytes, big-endian)
|
||||
- Packet number (2 bytes, big-endian, 0-indexed)
|
||||
- Final packet number (2 bytes, big-endian, 0-indexed)
|
||||
- Compressed markdown text (remaining bytes, ZSTD)
|
||||
|
||||
### Edit Advanced Text (0x0007)
|
||||
|
||||
Edit or delete existing Advanced Text messages. Use same Message ID to replace existing message. Empty compressed text deletes the message. Client replaces original when final packet received.
|
||||
|
||||
**Data Structure:** Same as Advanced Text (0x0006)
|
||||
@@ -160,12 +174,14 @@ Edit or delete existing Advanced Text messages. Use same Message ID to replace e
|
||||
## Implementation Guidelines
|
||||
|
||||
### Validation Requirements
|
||||
|
||||
- All length fields must not exceed their specified maximums
|
||||
- Username/Client ID lengths must match actual string lengths
|
||||
- Message data must not exceed 1000 bytes (including nonce)
|
||||
- Packet numbers must be sequential and within final packet range
|
||||
|
||||
### Connection Lifecycle
|
||||
|
||||
1. **Connect** to server (TCP/WebSocket)
|
||||
2. **Subscribe** to required message types
|
||||
3. **Send keepalive** every 30 seconds when idle
|
||||
@@ -173,6 +189,7 @@ Edit or delete existing Advanced Text messages. Use same Message ID to replace e
|
||||
5. **Handle** out-of-order packets for Advanced Text
|
||||
|
||||
### Common Issues
|
||||
|
||||
- **Encryption fails**: Ensure message type in additional data matches packet header
|
||||
- **Messages dropped**: Check total size ≤ 1000 bytes including nonce
|
||||
- **Connection timeout**: Verify keepalive frequency
|
||||
@@ -188,4 +205,4 @@ Edit or delete existing Advanced Text messages. Use same Message ID to replace e
|
||||
- **Multi-packet support** for long messages
|
||||
- **TCP and WebSocket** transport options
|
||||
|
||||
This is a documentation-only repository. The protocol specification is final and changes are not permitted.
|
||||
This is a documentation-only repository. The protocol specification is final and changes are not permitted.
|
||||
|
||||
Reference in New Issue
Block a user