All of the written below is my thoughts, if I’ve made a mistake please consider warning me to fix falses
Quick note: This post was made to show a way to use Remotes without any module interface is beneficial most of the time.
Of course, some modules might be useful for you; some of them might convert your data into bytes and split them into smaller parts to send them one by one to reduce data size. But you have to consider that you never gain something without losing anything. speed = data-size / seconds (v=m/s). At the end of the day, you have to wait for other parts of the complete data.
Before the RunContext property, we were not able to run client and server scripts in the same static directory, so this situation forced us to stack our events to ReplicatedStorage with certain names. But this technique was impractical, whenever we wanted to move our scripts to different places or wanted to publish them in ToolBox for OpenSource behavior, we also had to package them to make systems functional.
We(or at least I am) tried to create them on ServerSide and had to check them on the client side to keep our Systems clear and portable. This was the reason for me to make NetTS
I’ve used it many times before the RunContext property, which helped me a lot with portable Client-Client, Server-Server, and Client-Server interactions.
Thankfully RunContext came into our lives.
From now on we can package everything in one static directory that is required for a specific system.
Your program overflow can be like this
--game:GetService("....")
--game:GetService("....")
local System = script.Parent
local RemoteEvent = System.RemoteEvent
local RemoteFunction = System.RemoteFunction
local Remotes = {}
RemoteEvent.OnServerEvent:Connect(function(Player, event, ...)
-- Possible Middleware can be placed here!
Remotes[event](Player, ...)
end)
local FunctionRemotes = {}
RemoteFunction.OnServerInvoke = function(Player, event, ...)
-- Possible Middleware can also be placed here!
return FunctionRemotes[event](Player, ...) -- Be sure to not forget about the "return" statement here!
end
function Remotes.HelloWorld(Player, Paremeter1, Parameter2 --[[etc...]])
print(`{Player.Name} said {Parameter1} and {Parameter2}`)
-- Output would be like "Monotter said Hello and World" if I run `RemoteEvent:FireServer("HelloWorld", "Hello", "World")` on the client.
end
function Remotes.Multiply(Player, Number1, Number2)
return Number1 * Number2 -- You get the idea!
end
I hope you’ve got the point. Just be sure that the module that you want to use solves a problem that you will be faced with. They have to be made to make our lives easier, not messier.