Writing custom middleware
If you want to write a custom middleware (e.g. for logging, or other purposes), you must write a Net.Middleware
compatible function. This is similar to a middleware function in rodux.
This function is given a callback nextEvent
, and instance
(the remote instance).
It expects you to return a function, which is given the sender
, and the args
(arguments) after that, that were passed.
This inner function should call and return nextEvent
(if you want it to succeed) - or return nothing (if you don't want your remote to succeed with calling)
- roblox-ts
- luau
For example, if we want a specific remote to only be callable by administrators in our game:-
- roblox-ts
- luau
The above middleware, when applied to a remote will only continue and call the callback/listener if the next
/nextMiddleware
callbacks are called. Otherwise RbxNet will drop these requests.