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
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.
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.
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.
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
Is this compatible with BindableEvents?
Is this available on Roblox-TS?
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
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
You need to require() the module
I donāt believe so, would love support though.
Is there a way to disconnect OnClientEvent/OnServerEvent using this module?
Has anyone had any issue with memory leaks using this module?
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.
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.
Alrighty, I will definitely keep an eye on it, thank you!
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.
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
})
From what I have heard, this is something you should not do. Exploiters can manipulate the data being sent back to the server
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?