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

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

Not sure if you are aware of this, if you arenā€™t, with deferred events enabled, calling any remotes via the module causes a script timeout exception. It seems that the SafeFireEvent function causes this error.

--Deferred events are on
--Line 226
FastSpawn(function(...) --Stack Trace points to this line raising the error
                        --assuming this below while loop is the cause
	while running and index > 0 do
		local fn = callbacks[index]
			index -= 1
				
			fn(...)
		end
	end, ...)
	
	running = false
	end
end

I am not sure of any solutions for the error at this time, but if I do figure out something, Iā€™ll edit this post with a fix

8 Likes

Is this compatible with BindableEvents?

4 Likes

Is this available on Roblox-TS?

2 Likes

no, also use a signal module bindable events are disgusting

local Signal = {}
Signal.__index = Signal

local Connection = {}
Connection.__index = Connection

function Signal.New()
	return setmetatable({
		Connections = {};
		Yields = {};
	}, Signal)
end

function Signal:Fire(...)
	for _, v in ipairs(self.Connections) do
		coroutine.wrap(v.func)(...)
	end

	for k, v in ipairs(self.Yields) do
		coroutine.resume(v, ...)
		table.remove(self.Yields, k)
	end
end

function Signal:Connect(func)
	local connection = setmetatable({
		func = func;
		orgSelf = self;
	}, Connection)

	table.insert(self.Connections, connection)
	return connection
end

function Signal:Wait()
	table.insert(self.Yields, coroutine.running())
	return coroutine.yield()
end

function Connection:Disconnect()
	for k, v in ipairs(self.orgSelf.Connections) do
		if v == self then
			table.remove(self.orgSelf.Connections, k)
		end
	end
	setmetatable(self, nil)
end

function Signal:Destroy()
	for _, v in ipairs(self.Connections) do
		v:Disconnect()
	end

	for _, v in ipairs(self.Yields) do
		coroutine.resume(v)
	end

	setmetatable(self, nil)
end
8 Likes

Hi,

I have copied the Server & Client examples but then I run I get the error below in the client script, I have the network module in ReplicatedStorage I used game:GetService(ā€œInsertServiceā€):LoadAsset(5023179796):GetChildren()[1].Parent = game.ReplicatedStorage

BindEvents is not a valid member of ModuleScript ā€œReplicatedStorage.Networkā€ - Client - NetworkTest-LS:5

Thanks

2 Likes

You need to require() the module

1 Like

I donā€™t believe so, would love support though.

2 Likes

Is there a way to disconnect OnClientEvent/OnServerEvent using this module?

1 Like

Has anyone had any issue with memory leaks using this module?

1 Like

I have not, however, my game is experiencing some memory leaks from the unoptimized code Iā€™ve written. But if you are experiencing memory leaks and it is from this module, can you please share your experiences? I would like to avoid or cleanup potential memory leaks.

2 Likes

With most code in my game disabled aside from modules dependent on the network module in my game, I am experiencing some memory leak with the lua heap ; however, It could simply be due to me having the developer console open for monitoring as it has had memory leak issues in the past, and some corescript elements do seem to slowly rise indefinitely as the game stays open, but not enough to warrant them being the general cause of the games memory constantly rising.

3 Likes

Alrighty, I will definitely keep an eye on it, thank you!

1 Like

A bit off topic but do you know if this is still the case? Iā€™m planning on creating a module for client/server interaction and want to know if this is still an issue.

1 Like

HI,

Is it possible to setup BindFunctions on the clientside? I am trying to get a value from the client from a server script.

Below is what I have and its not working, the client Events are working

On the server I am running
local test = Network:FireClient(player,ā€œServerRequestTestā€)

On the client I have
Network:BindFunctions({
ServerRequestTest = function(player)
local test = ā€œWorkedā€
return test
end
})

1 Like

From what I have heard, this is something you should not do. Exploiters can manipulate the data being sent back to the server

1 Like

Hi, I use this module all the time in my code but recently Iā€™ve encountered an issue

  15:18:06.530  Infinite yield possible on 'ReplicatedStorage:WaitForChild("Communication")'  -  Studio
  15:18:06.530  Stack Begin  -  Studio
  15:18:06.530  Script 'ReplicatedStorage.Network', Line 103  -  Studio - Network:103
  15:18:06.530  Stack End  -  Studio

This never happened before but now itā€™s happening, not sure how to fix, any ideas why this happens?

1 Like