updated docs, minor changes
This commit is contained in:
53
README.md
53
README.md
@@ -20,6 +20,19 @@ HomesteadGateway is a WebSocket-based message routing gateway that facilitates b
|
||||
|
||||
---
|
||||
|
||||
## Quick Start
|
||||
|
||||
1. Start the gateway (build/run your application that embeds the WebSocket gateway).
|
||||
2. Connect a client to the WebSocket endpoint:
|
||||
- URL: `ws://<host>:<port>/sync?api_key=<your_api_key>`
|
||||
3. Immediately send a handshake JSON with type `mod` or `bot`.
|
||||
4. On success, you’ll receive `{"status":"connected","type":"mod|bot"}`.
|
||||
5. Exchange messages as JSON.
|
||||
|
||||
See the full details below.
|
||||
|
||||
---
|
||||
|
||||
## Architecture
|
||||
|
||||
### Connection Types
|
||||
@@ -116,15 +129,15 @@ For bots (Discord bots, etc.):
|
||||
{
|
||||
"type": "bot",
|
||||
"data": {
|
||||
"channel_id": "123456789"
|
||||
"bot_id": "discord-bot-123"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**Fields:**
|
||||
- `channel_id` (string, required): The channel ID this bot monitors
|
||||
- `bot_id` (string, required): The bots ID
|
||||
|
||||
**Note:** Only **one bot connection** is allowed at a time. Connecting a new bot will close the existing bot connection.
|
||||
**Note:** Only **one bot connection** is allowed at a time. Trying to connect a new bot will result in an `409 Conflict` Error.
|
||||
|
||||
### Step 3: Receive Acknowledgment
|
||||
|
||||
@@ -134,7 +147,7 @@ After sending the handshake, wait for an acknowledgment:
|
||||
```json
|
||||
{
|
||||
"status": "connected",
|
||||
"type": "mod" // or "bot"
|
||||
"type": "mod|bot"
|
||||
}
|
||||
```
|
||||
|
||||
@@ -344,7 +357,7 @@ conn.SetPongHandler(func(appData string) error {
|
||||
**Handshake Errors:**
|
||||
- `400` - Malformed handshake JSON
|
||||
- `401` - Invalid or missing API key
|
||||
- `409` - Bot already connected (for bot handshakes)
|
||||
- `409` - Bot already connected (only for bot handshakes)
|
||||
- `500` - Internal server error
|
||||
|
||||
**Message Errors:**
|
||||
@@ -378,9 +391,9 @@ Handle other WebSocket closures as unexpected errors.
|
||||
|
||||
## Rate Limits & Restrictions
|
||||
|
||||
- **Message Size Limit:** 1 MB per message (configurable)
|
||||
- **Message Size Limit:** 2 MB per message (configurable)
|
||||
- **Read Limit:** Messages exceeding the limit will close the connection
|
||||
- **Concurrent Mods:** Multiple mods can connect to the same channel ID (different server IDs)
|
||||
- **Concurrent Mods:** Multiple mods *can* connect to the same channel ID (different server IDs)
|
||||
- **Concurrent Bots:** Only **one bot connection** allowed globally
|
||||
|
||||
---
|
||||
@@ -426,32 +439,6 @@ Use mutex/locks when writing to WebSocket from multiple threads.
|
||||
|
||||
---
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Connection Refused
|
||||
- Verify the gateway is running
|
||||
- Check the port is correct (default: 3333)
|
||||
- Ensure firewall allows connections
|
||||
|
||||
### 401 Unauthorized
|
||||
- Verify API key is correct
|
||||
- Check API key is properly URL-encoded in query string
|
||||
|
||||
### Handshake Timeout
|
||||
- Ensure handshake is sent within 60 seconds of connection
|
||||
- Verify handshake JSON is correctly formatted
|
||||
|
||||
### Messages Not Received
|
||||
- Check `channel_id` matches between mod and bot
|
||||
- Verify recipient is connected
|
||||
- Check queue status in acknowledgments
|
||||
|
||||
### Connection Drops
|
||||
- Ensure pong responses are sent to pings
|
||||
- Check network stability
|
||||
- Implement reconnection logic
|
||||
|
||||
---
|
||||
|
||||
## API Reference
|
||||
|
||||
|
||||
Reference in New Issue
Block a user