CrossServerManager v1.1.5 - Flexible Subscriptions
A Roblox module for advanced cross-server messaging, now with flexible subscription types. Supports reliable message delivery, retries, deduplication, replay, throttling, custom monitoring, and a full offline simulation mode for testing without live Roblox servers.
What’s New in v1.1.5
- Flexible Subscriptions – New subscription types added:
SubscribeOnce– Receive only the first message for a topicSubscribeUntil(time)– Receive messages for a specified duration in seconds
- Minor bug fixes and stability improvements
Subscription Types Example
local csm = require(path.to.CrossServerManager)
csm:Start()
-- Normal subscribe (receives all messages)
csm:Subscribe("Topic", function(data)
print("Received data:", data, "\n")
end)
-- Subscribe once (first message only)
csm:SubscribeOnce("Topic", function(data)
print("Received data once:", data, "\n")
end)
-- Subscribe with a timeout of 10 seconds
csm:SubscribeUntil("Topic", function(data)
print("Received data until:", data, "\n")
end, 10)
-- Publish a message
csm:Publish("Topic", "Hello")
Features
- Reliable cross-server messaging
- Automatic retry with exponential backoff
- Deduplication for safe message processing
- Message replay for new/late servers
- Per-message-type throttling & configuration
- Dead-letter queue on repeated failure
- Custom monitoring event hooks
- Flush pending messages on server shutdown
- Flexible subscription control (pause, resume, unsubscribe)
- Version check and update notification
- Rate limit awareness with degradation
Installation
- Copy
CrossServerManager.luainto your Roblox project (ideally inServerScriptService). - Require it in your server-side script:
local CrossServerManager = require(path.to.CrossServerManager)
Initialization / Starting the Module
Before using the module, you should start its internal processes.
Call :Start() as early as possible on the server (e.g., at the top of your main server script):
local CrossServerManager = require(path.to.CrossServerManager)
CrossServerManager:Start() -- Initialize
You only need to call :Start() once per server, Set Variable Debug to Enable _log()
Basic Usage
note: Set localPublish to true to publish the message only locally on the current server. This is useful for testing or when you want to avoid sending messages across servers.
-- Subscribe to a topic
local subscription = CrossServerManager:Subscribe("MyTopic", function(payload, uuid, seq, messageType)
print("Received:", payload)
end)
-- Publish a message
local uuid, success, err = CrossServerManager:Publish("MyTopic", {data = 123}, "default", 60)
-- Pause, resume, or unsubscribe from a topic
subscription:Pause()
subscription:Resume()
subscription:Unsubscribe()
Replay Missed Messages
Replay is one of the most powerful features of this module. If your server was offline or you want to “catch up” on messages sent before joining,
use ReplayMissedMessages to process messages from a given point in time:
-- Replay all messages for "MyTopic" sent since a specific timestamp (e.g., last hour)
local oneHourAgo = os.time() - 3600
CrossServerManager:ReplayMissedMessages("MyTopic", oneHourAgo)
-
This will fetch and deliver up to the last 40 messages for the topic that were sent since the given timestamp.
-
Note: Messages must have been published with messageRetentionTime > 0 and not expired to be eligible for replay.
- Deduplication ensures you won’t process the same message twice.
- Useful when a new server starts or for recovering missed events.
Advanced Usage
Monitoring Events
CrossServerManager:MonitoringOn("onMessageSent", function(uuid, topic, payload, seq, messageType)
print("Message sent:", uuid)
end)
Full API Overview
:Start()– Initialize module:Subscribe(topic, callback)– Normal subscription:SubscribeOnce(topic, callback)– Receive first message only:SubscribeUntil(topic, callback, duration)– Time-limited subscription:SubscribeOncePerSender(topic, callback)– One message per sender UUID:Publish(topic, payload, messageType, messageRetentionTime, localPublish)– Send a message:ReplayMissedMessages(topic, sinceTimestamp, [targetServer])– Replay messages:BulkPublish(messages, localBulkPublish)– Publish multiple messages:FlushPendingMessages()– Flush queued messages:MonitoringOn(eventName, callback)– Custom monitoring hooks:Unsubscribe(topic, id)– Remove subscription:GetServerId()– Current server ID:SetDebugMode(enabled)– Enable debug logging- Offline mode only:
SetMode,CreateVirtualSimulationServer,SetLimitSimulation,GetLimitStats
License
MIT - see LICENSE for details.
GitHub: V1nyI
- Useful
- Neutral
- Confusing
- Bad
- Yes
- Maybe
- No
