Server Message System
Comprehensive documentation for the BlinkBox Server Message Addon
Introduction
The Server Message System is a robust in-game mail solution that enables administrators to send direct messages to players. It supports persistent storage, read status tracking, and optional HTML formatting for rich text content.
Key Features
- Persistent Storage: Messages are stored in the SQL database, persisting across sessions.
- Admin Panel Integration: Directly integrated into the MFPS Admin Panel for easy access.
- Rich Text Support: Admins can use HTML tags to format messages (bold, color, size, etc.).
- Real-time Status: Tracks read/unread status and allows deletion.
- Local Caching: Optimizes network usage by caching messages for a configurable duration.
Setup & Installation
1. Database Setup
- Upload
bl_Servermail.phpto your web server in the same directory as your MFPS PHP files. - The system will automatically create the required
bl_server_messagestable upon the first request if it doesn't exist.
2. Unity Setup
- Add the ServerMessageManager component to your scene (or rely on its auto-instantiation).
- Place the ServerMailboxUI prefab in your Lobby scene canvas.
- (Optional) Add the ServerMailAdminUI prefab to your Admin Panel canvas if not already present.
Admin Features
The system provides a dedicated interface for administrators to manage communications.
Sending Messages
From the Admin Panel, navigate to the Server Mail section:
- Target User: Enter the exact username of the recipient.
- Subject: A short title for the message.
- Body: The main content. Supports standard text.
- HTML Mode: Toggle this to enable rich text formatting (e.g.,
<b>Bold</b>,<color=red>Alert</color>).
Player Features
Players have access to a full mailbox interface.
Inbox Management
- Auto-Refresh: The inbox checks for new messages automatically every 60 seconds (configurable).
- Sorting: Sort messages by Newest, Oldest, or Unread status.
- Bulk Actions: "Read All" and "Delete All" buttons for quick management.
Message Viewing
Clicking a message expands it to show the full content. If the message contains HTML, it will be rendered accordingly by TextMeshPro.
Architecture
ServerMessageManager
The core singleton that handles all networking and logic.
- Caching: Implements a
MessageCachesystem to reduce database load. - Retry Logic: Automatically retries failed requests based on configuration.
- Logging: Features a categorized logging system (Server, Message, Error, Warning).
Data Structure
The MessageData class defines the structure of a message:
[System.Serializable]
public class MessageData
{
public string id;
public string title;
public string bodyMessage;
public string sender;
public string receiver;
public long timestamp;
public bool isRead;
public bool isDeleted;
}
Configuration
Settings can be adjusted on the ServerMessageManager component.
| Setting | Default | Description |
|---|---|---|
| Request Timeout | 10s | Max time to wait for server response. |
| Max Retries | 3 | Number of attempts for failed requests. |
| Cache Duration | 300s | Time (in seconds) to keep messages in local cache (5 mins). |
| Refresh Interval | 60s | How often the UI auto-refreshes the inbox. |
Logging Colors
You can customize the console log colors for different categories to make debugging easier.