EasyNetwork - Creates remote functions/events for you so you don't have to!

Cool module!

This is interesting.
I’ve also made something for quick client-to-server communication which uses a single RemoteFunction.

I was unaware of the true cost of sending strings through the internet.
I’m guessing that Roblox takes care of assigning IDs to functions to reduce this cost.
So by making a bunch of RemoteFunctions you improve network performance?

I have yet to see any serious performance issues with the way I’m doing it now (probably because it hasn’t been used in anything of a large enough scale) but I will definitely consider making an updated version that takes this into account, or using this module.

4 Likes

No harm in switching to this if it fits your game’s workflow, should have everything you need.

Using one remote can be done, but it’s ill-advised due to the bandwidth overhead of sending string-identifiers over the network. This is mostly an issue when you send data frequently of course.

4 Likes

I get that for convenience’s sake it is nicer having one module to require for both server and client however you are potentially exposing server-side security flaws to exploiters.

1 Like

How? The client still can’t read any of your server souce code. Them being able to read the network module doesn’t really matter

4 Likes

Can you elaborate on how using remote events in place of remote functions is faster? I noticed in the module you wait at least .5 seconds if the remote event you spawned doesn’t fire right away. I 'm guessing it fires the event right after the event code is executed instead of yielding a certain amount that a remote function would wait for? I do like this though I was previously using identification strings using a single remote event/function, but now I am going to switch over to this. Thank you for sharing this with everyone.

2 Likes

Of course! I’m not sure why RemoteFunctions are slower, I just know they are so we use RemoteEvents to implement InvokeServer

3 Likes

I’ve been implementing this module into my game but I came across an issue. There doesn’t seem to be a way to disconnect any OnClientEvent/OnServerEvent event connections when using the BindEvents method. Do you think you could update the module to add a way to do this?

1 Like

I noticed this module doesn’t have an API for BindableEvents. Does your game not utilize Server to Server communication? How would you go about this if needed? Would you just implement them the standard way?

1 Like

Typically I have server modules communicate with each other just by requiring each other and calling public methods, with a little setmetatable trick to eliminate the stack overflow problem of circular dependencies. BindableEvents also work though, but I typically just use that if I’m wanting to listen for a specific event.

I didn’t include that kind of stuff in this module since it’s easy enough to add on your own and isn’t really relevant to what this module is for

1 Like

little setmetatable trick? mind enlightening us?

2 Likes

Does it clean out event connections to prevent memory leaks?

1 Like

Hi there~ @tyridge77

Thank you for sharing your creation with us, this is very interesting stuff.

Would you kindly create a link to Source code (preferably Github and/or Pastebin) for people who want to read the source but don’t have any access to a PC or maybe want to contribute to the source

1 Like

Does this not support :BindFunctions on the client?

1 Like

Nothing against this, but how much performance would this take away if I was doing a bunch of different remotes?
Because if it is creating them, it is using a small amount of processing power to replicate them.

1 Like

Really cool module, was super simple to implement into my workflow!

Only thing I noticed though was that there’s no out-of-the box support for Events that are only ‘Server=>Client’ and don’t have a Server-Sided Callback.

I was able to add support super easily thanks to the cleanliness of your code, but it would still be cool to see methods like “CreateEvents” & “CreateFunctions” for those events/functions that don’t require OnServerEvent/OnServerInvoke connections and are only intended to be used with FireClient/InvokeClient.

3 Likes

Sorry if this has already been fixed and I’m on an outdated version.

I had this error occur to me on one of my clients in-game:
ReplicatedStorage.MyGame.Network:593: invalid argument #1 to 'char' (invalid value) ReplicatedStorage.MyGame.Network, line 593 - function ToByteString ReplicatedStorage.MyGame.Network, line 645 - function InvokeServer

I found the root cause (pic below)
It looks like ResponseCounter is used to basically created a pseudo-unique id for tracking responses from the client, to the server, and it is only allowed to increment up, with a rolling modulo on 2^32 to presumably keep it in check from having an integer overflow and going into negative numbers.

Somehow one of my clients got a negative integer going into ToByteString. I assume either 2 ^32 rolled over into a negative int or ResponseCounter did. I’ve re-written the logic to something a little simpler to hopefully prevent this, won’t know for a few weeks of 0 issues, though.

1 Like

Updated with some improvements/fixes (i.e fixed issue where order of remotes was lost if they arrive before event is bound) and also added some new methods

4 Likes

Seems super cool and might be using this! Will this also have a way to implement debounce to events or we will have to do this.

3 Likes

I am leaving a post so I can come back to this tomorrow morning.

I’ll definitely take a look into this piece of art.

3 Likes

I had an idea to add onto EasyNetwork, could do it on my own code but thought it would be nice to have in the main “branch” of it -

The ability to do server → server events through the API. Right now you can only do Server → Client or Client → Server.
It’d be nice to have the same easy API if I wanted to do a Server → Server pattern

The API actually wouldn’t change, still use Network:FireServer() and Network:InvokeServer(), just look at registered Client events first, if not found there, look at events setup using Network:BindFunctions() from the server. And if there’s a duplicate name used in Client/Server you could maybe throw a warning to let the dev know.

2 Likes