Not supported anymore. Use the modern version, BridgeNet
NetworkObject
An extremely light-weight, easy-to-use, abstraction/wrapper for networking!
NetworkObject is primarily an abstraction that lets you take away the annoyances of RemoteEvents. It provides a very easy API that minimizes the separations between server and client. Both the server and the client utilize the same functions, so there’s no looking if the script runs on the client, or the server!
Alongside having a very easy-to-use API, it’s also usable for everyone. It doesn’t matter how you like to structure your code, because the API acts as if it’s a reference to a remote event. You could put a constructor at the top of your script, and act as if it’s a normal RemoteEvent with a different API. You could put it into an object, and use it for composition.
The main benefit of using this module, though, isn’t the abstraction, or the easy-to-use API. It’s the timed connections! This simply means that synchronize the time that connections / fires go through the RemoteEvents. I do this for quite a few reasons.
- It can save on network send / receive if you’re sending out remote calls more than one time per heartbeat
- Synchronization can decrease the perceived response time for the player
- Being able to control when you receive / send remote calls is nice
- The ability to debug performance loss with networking
Example Use
local NetworkObject = require(path.to.NetworkObject)
local Hello = NetworkObject.new("HelloWorld")
Hello:Connect(function()
print("Hello World!")
end)
Hello:Fire()
Link to Script:
API
NetworkObject.new(name, yields, timeout)
Creates a new NetworkObject.
Name: The name of the RemoteEvent
Timeout (Client only): Timeout for :WaitForChild().
Returns: NetworkObject
NetworkObject:Fire(plrOrAll, ...)
Fires the RemoteEvent within the NetworkObject.
plrOrAll (Server only): If the parameter is a PlayerInstance, it will fire to the specified client. If it’s a string with the text “all”, it will fire to all clients.
Returns: nil
NetworkObject:Connect(function)
Connects to the RemoteEvent within the NetworkObject.
Function: Connects to the RemoteEvent. Passes in specified arguments, and also a PlayerInstance if it’s on the server.
Returns: Connection
NetworkObject:Destroy()
Destroys the NetworkObject.
No parameters.
Returns: nil
Roadmap
I aim to update this module often! There will be lots of new features coming, such as:
- Rewrite it to use separate client/server functions that are set when .new() is called
- Configuration to enable/disable certain aspects like instance caching
- Format checking
- Rate limiting
- Returning promises
- Authors for server-scripts
Done:
- Instance caching
- Timed connections
If you use this for any of your projects, by all means reply to this thread! It means a lot to me. If you find any bugs, please let me know. This is my personal networking module, so I update it often.