Server
Server-side networking module for receiving client data and broadcasting events
Wisp.Fire
Server.Fire(remoteName: string, player: Player, ...: any)Send data to specific player.
Parameters:
remoteName: Remote identifierplayer: Target player...: Data to send (supports all Roblox types + tables)
Example:
local Wisp = require(ReplicatedStorage.Wisp).Server
Wisp.Fire("notification", player, "Welcome!", Color3.new(0, 1, 0))Wisp.FireAll
Server.FireAll(remoteName: string, ...: any)Broadcast data to all connected players.
Parameters:
remoteName: Remote identifier...: Data to send
Example:
Wisp.FireAll("server_announcement", "Server restarting in 5 minutes")Wisp.FireList
Server.FireList(remoteName: string, players: {Player}, ...: any)Send data to list of players.
Parameters:
remoteName: Remote identifierplayers: Array of target players...: Data to send
Example:
local team = {player1, player2, player3}
Wisp.FireList("team_message", team, "Your team scored!")Wisp.FireExcept
Server.FireExcept(remoteName: string, except: Player | {Player}, ...: any)Broadcast to all except specified player(s).
Parameters:
remoteName: Remote identifierexcept: Player or array of players to exclude...: Data to send
Example:
-- Notify everyone except the killer
Wisp.FireExcept("player_death", killer, victim.Name, "was eliminated")Wisp.Connect
Server.Connect(remoteName: string, callback: (player: Player, ...any) -> ()): () -> ()Register callback for client events.
Parameters:
remoteName: Remote identifiercallback: Function called when client fires event (receives player as first argument)
Returns:
() -> (): Disconnect function
Example:
Wisp.Connect("player_action", function(player, action, value)
if action == "jump" then
print(player.Name, "jumped with power", value)
end
end)Wisp.Once
Server.Once(remoteName: string, callback: (player: Player, ...any) -> ())Register one-time callback.
Parameters:
remoteName: Remote identifiercallback: Function called once when client fires event
Returns:
() -> (): Disconnect function
Example:
Wisp.Once("first_client_ready", function(player)
print("First player ready:", player.Name)
end)Wisp.Invoke
Server.Invoke(remoteName: string, player: Player, ...: any): ...anyCall client function and wait for response.
Parameters:
remoteName: Remote identifierplayer: Target player...: Arguments to send to client
Returns:
...any: Response values from client
Example:
local clientFPS = Wisp.Invoke("get_fps", player)
if clientFPS and clientFPS < 30 then
-- Reduce graphics for this player
endWisp.OnInvoke
Server.OnInvoke(remoteName: string, callback: (player: Player, ...any) -> ...any)Register handler for client invoke requests.
Parameters:
remoteName: Remote identifiercallback: Function that returns response values (receives player as first argument)
Example:
Wisp.OnInvoke("purchase_item", function(player, itemName, cost)
local profile = getProfile(player)
if profile.coins >= cost then
profile.coins -= cost
profile.inventory[itemName] = true
return true, "Purchase successful"
else
return false, "Insufficient coins"
end
end)Wisp.UseConfig
Server.UseConfig(config: RemoteConfig, remoteName: string?)Set encoding/batching configuration globally or per-remote.
Parameters:
config: Configuration table (see RemoteConfig)remoteName(optional): Apply only to this remote
Example:
-- Global config
Wisp.UseConfig({
encode = {mode = "compressed", compression = "auto"},
batching = "unreliable",
maxBatchSize = 50
})
-- Per-remote config
Wisp.UseConfig({
encode = {mode = "delta", schema = playerStatsSchema},
rateLimit = 0.1
}, "player_stats")Wisp.UseSchemas
Server.UseSchemas(schemas: {[string]: Schema}, migrations: {[string]: MigrationMap}?)Register schemas for automatic validation and migration.
Parameters:
schemas: Table mapping remote names to schema definitionsmigrations(optional): Table mapping remote names to migration maps
Example:
local schemas = {
player_data = {
version = 2,
fields = {
{name = "id", type = Types.number()},
{name = "username", type = Types.string(20)},
{name = "level", type = Types.integer()}
}
}
}
local migrations = {
player_data = {
[1] = function(data)
data.level = data.level or 1
return data
end
}
}
Wisp.UseSchemas(schemas, migrations)Wisp.UseCompression
Server.UseCompression(mode: CompressionMode, remoteName: string?)Enable compression for bandwidth savings.
Parameters:
mode:"auto"|"lz4"|"deflate"|"zstd"|"none"remoteName(optional): Apply only to this remote
Example:
-- Global compression
Wisp.UseCompression("auto")
-- Compress only large data remotes
Wisp.UseCompression("deflate", "map_data")
-- Server-only: use Zstd for best compression
Wisp.UseCompression("zstd", "world_state")Wisp.UseDelta
Server.UseDelta(schema: Schema?, remoteName: string?)Enable delta encoding (send only changed fields).
Parameters:
schema(optional): Schema for delta validationremoteName(optional): Apply only to this remote
Example:
local statsSchema = {
fields = {
{name = "hp", type = Types.number()},
{name = "mp", type = Types.number()},
{name = "xp", type = Types.number()}
}
}
Wisp.UseDelta(statsSchema, "player_stats")
-- First send: all fields
Wisp.Fire("player_stats", player, {hp = 100, mp = 50, xp = 0})
-- Next sends: only changed fields
Wisp.Fire("player_stats", player, {hp = 80, mp = 50, xp = 0}) -- Only hp sentWisp.UseBatching
Server.UseBatching(enabled: boolean)Enable/disable automatic batching globally.
Parameters:
enabled:trueto enable batching,falseto disable
Example:
-- Disable batching for low-latency mode
Wisp.UseBatching(false)Wisp.SetUnreliable
Server.SetUnreliable(remoteName: string, unreliable: boolean)Configure remote to use UnreliableRemoteEvent (lower latency, packet loss possible).
Parameters:
remoteName: Remote identifierunreliable:truefor UnreliableRemoteEvent,falsefor RemoteEvent
Example:
-- High-frequency position updates
Wisp.SetUnreliable("player_position", true)Wisp.SetBatchMode
Server.SetBatchMode(remoteName: string, mode: BatchMode)Set batching behavior for remote.
Parameters:
remoteName: Remote identifiermode:"never"|"unreliable"|"reliable"
Example:
Wisp.SetBatchMode("critical_event", "never") -- Send immediately
Wisp.SetBatchMode("player_position", "unreliable") -- Batch, fast
Wisp.SetBatchMode("player_stats", "reliable") -- Batch, guaranteedWisp.SetBatchPriority
Server.SetBatchPriority(remoteName: string, priority: number)Set send priority within batches (lower = sent first).
Parameters:
remoteName: Remote identifierpriority: Priority number (0-999, lower = higher priority)
Example:
Wisp.SetBatchPriority("player_health", 1) -- High priority
Wisp.SetBatchPriority("player_cosmetic", 100) -- Low priorityWisp.SetMaxBatchSize
Server.SetMaxBatchSize(size: number)Set max packets per batch before force flush.
Parameters:
size: Maximum number of packets in a batch
Example:
Wisp.SetMaxBatchSize(100) -- Larger batches = more efficient, higher latencyWisp.SetRateLimit
Server.SetRateLimit(limit: number, remoteName: string?)Set minimum interval between client sends (anti-spam protection).
Parameters:
limit: Minimum seconds between sends per playerremoteName(optional): Apply only to this remote
Example:
-- Global: max 10 requests/sec per player
Wisp.SetRateLimit(0.1)
-- Critical endpoint: 1 request/sec max
Wisp.SetRateLimit(1.0, "admin_command")
-- High-frequency data: 20 updates/sec max
Wisp.SetRateLimit(0.05, "player_position")Wisp.EnableDeltaSync
Server.EnableDeltaSync(remoteName: string?)Enable delta cache hash verification.
Parameters:
remoteName(optional): Apply only to this remote
Example:
Wisp.EnableDeltaSync("player_stats")Wisp.FlushBatches
Server.FlushBatches()Immediately send all queued batches to all players.
Example:
-- Critical state update
Wisp.FireAll("game_state", newState)
Wisp.FlushBatches() -- Send immediately