function ServerEvent:FireAllClients(data)
-- Type checking if enabled
if self.TypeDefinition then
local typeCheckResult = TypeChecker:Validate(data, self.TypeDefinition)
if not typeCheckResult.success then
error(string.format("[NetRay] Type validation failed for event %s: %s",
self.Name, typeCheckResult.error or "Unknown error"))
return
end
end
-- Run middleware
local processedData = self.ServerManager:InvokeMiddleware(self.Name, nil, data)
if processedData == false then
-- Middleware blocked this event
return
end
-- Use DynamicSender to optimize batch sending
local sendData = processedData or data
local allPlayers = Players:GetPlayers()
-- Use SendToMultiple for batch optimization
local result = DynamicSender:SendToMany(self.RemoteEvent, sendData, allPlayers)
-- Log the batch send if debugging is enabled
if self.ServerManager.DebugEnabled then
print(string.format("[NetRay] Event %s fired to %d clients with batch optimization",
self.Name, #allPlayers))
end
end
I think I know the issue: Youâre trying to send the data before the player can receive/load in.
replace SendToMany Function with this; it will stop the error but wonât guarantee your client will get it
function NetRaySender:SendToMany(remote: RemoteEvent, data: any, targets: { Player })
if not remote then
warn("[NetRaySender] Cannot SendToMany: RemoteEvent is nil.")
return
end
-- Prepare single item data once, marked as NOT batch
local preparedData = prepareDataForSend(data, false, NetRaySender.Config.ForceCompressSingle) -- isBatch = false
if not preparedData then
warn("[NetRaySender] Failed to prepare data for SendToMany:", data)
return
end
if NetRaySender.Config.DebugMode then
print(`[NetRaySender] Sending to { #targets } targets via SendToMany.`)
end
if not targets or #targets == 0 then
remote:FireAllClients(preparedData)
else
for _, target in ipairs(targets) do
if target and target.Parent then
remote:FireClient(target, preparedData)
end
end
end
end
NetRay v1.1.0 isnât out yet; I am still refining the dynamic sender and batching logic even more, but here is a video of a benchmark compared to other modules.
Modules in benchmark place (Not Mine)
versions:
bytenet: 0.4.3
zap: 0.6.19
blink: 0.17.0
packet: 1.2
netray 1.1.0
Note
Packet and Netray throttling were both disabled to get a fair result
NetRay v1.1.0 is still being refined and tested so results are not final
Results
NetRay and Blink have the lowest usage for bools (seems like Netray is slightly lower eyeballed)
NetRay performs the same on structofnumbers as the rest with the notable exception of blink, which performed the best
NetRay did send less packet data per frame compared to others, but the struct of numbers did have slightly higher overall kb/s sent on the roblox performance stats
No CPU or Ping changes or high usage, and FPS was stable
dont forget to give credit to suphi for using Cursor & Types module in ur v1.1.0, i see u copy pastes it and modifies some codes without giving credit on it.
Like I already said, I used parts for a base because I was already making one but he released it and I just modified and improved it and works better and with NetRay so I still donât see your point?
you seem quite mad
No, his module just had issues and kept going out of bounds when I tested his module, and couldnât handle tables etc
Rewrote compression algorithm (switched from LZW to LZ4)
Eliminated CPU usage
Eliminated all Ping issues
Eliminated FPS issues
Fix Minor bugs
Fixed unable to send blank remote calls
Rewrote Dynamic Sender (v1.2.8)
Improved Promise module
Rewrote all modules for proper type checking, etc
Implement Autocomplete functionality (for the most part)
Benchmarks
Peforms Better or as good as Blink in some cases
In other cases, it performs as well or has slightly more network usage for very complex tables
This is because netray automatically does everything for you and includes headerdata since it doesnât use pre-defined structures, however, it is not that much overall, only a few kb.
Dynamic Sender Rewirte
Now Dynamic Sender chooses the best option to send and serialises it for you without using the seriliastion module
Uses a complex metadata analysis to determine the best ways to send your data
edit: its not possible for me to ignore the warnings as i am trying to keep my game as clean as possible and i am frequently using the code analysis to eliminate type issues and the NetRay module makes it really hard for me to find issues that come from my game.
This is a pretty cool OSS project! The haters are out there but you can ignore them for the most part; they only exist to suck up your energy and prevent you from making your project the best it can be. Keep up the good work!
Enabling --!strict typechecking just makes more warnings pop up. Would you mind strictly typing the module in the future? This would make your job way easier.
Edit: The 201 warnings are still there after using the re-uploaded version.