cLib.Net - Networking System
cLib.Net provides a simplified, secure networking wrapper with automatic compression and rate limiting.
Features
- ✅ Auto-compression - Large data is compressed automatically
- ✅ Rate limiting - Prevent spam and exploits (server-side)
- ✅ Simplified API - Send tables directly, no manual serialization
- ✅ Debug mode - Easy troubleshooting
Quick Example
-- SERVER
cLib.Net.SetPrefix("MyAddon.")
cLib.Net.Register("PlayerData")
cLib.Net.Send("PlayerData", {
name = ply:Nick(),
score = 100,
items = playerItems
}, ply)
-- CLIENT
cLib.Net.SetPrefix("MyAddon.")
cLib.Net.Receive("PlayerData", function(data)
print(data.name, data.score)
PrintTable(data.items)
end)Configuration
-- Set message prefix (MUST match on client/server!)
cLib.Net.SetPrefix("MyAddon.")
-- Enable debug logging
cLib.Net.SetDebug(true)
-- Set compression threshold (default: 512 bytes)
cLib.Net.SetCompressionThreshold(1024)How Compression Works
1. Data is converted to JSON
2. If JSON size > threshold, it's compressed with util.Compress
3. Compressed data is sent with size header
4. Receiver decompresses and parses JSON
-- Force compression for specific messages
cLib.Net.SendCompressed("LargeData", bigTable, player)