RemoteTable-Light - Replicate tables over the network!

Unfortunately destroy signal is literally destroying the signal and getting rid of it completely with the given path. You can still store connections on your own and disconnect from each individual system.

Awesome! So for clarification, for temporary remote tables, following these three steps for clean-up should be enough to ensure no memory leaks with this module?

  1. RemoteTableServer.Destroy(token) is called on server-side
  2. Signal connections are cleaned up on client-side (the ones provided through GetSignal(...) => Connect)
  3. The table itself loses its reference (e.g. t = nil) on both the server & client side

I’m guessing that DestroySignal is there purely for convenience, if you decide to keep track of the paths you’re listening to instead of the individual connections.

I usually prefer to keep track of individual connections created through Maid objects and dispose of them when they’re no longer needed (e.g. when the RemoteTable is destroyed).

Note that if you listen to a temporary remote table that might be destroyed during runtime you are expected to disconnect on your own. Although If there is enough demand for it I might add a way to detect when a remote table is destroyed.

I could see the use cases, as currently the workaround would be to rely on other events that get triggered on the client (e.g. other player leaving must mean that RemoteTable is getting destroyed on the server).

1.1 is here!

  • Fixed: Unregister logic on client
  • Small correction to Changed signal behaviour

Awesome! So for clarification, for temporary remote tables, following these three steps for clean-up should be enough to ensure no memory leaks with this module?

When .Destroy is called on server client doesn’t clean up the connections in case remote table reconnects. But it’s pretty easy to change this behaviour and I might do it this way in 1.2 mainly because it makes sense when .Destroy is called it’s cleaned up on both server and client. So be on the lookout for updates!

I’m guessing that DestroySignal is there purely for convenience, if you decide to keep track of the paths you’re listening to instead of the individual connections.

Yes destroy signal is purely convinience as you can manage your own connections. However even if you manage your own connections the signal stays associated with the path given and only way to completely get rid of it is .DestroySignal. Although it is advised to keep track of the connections individually.

I could see the use cases, as currently the workaround would be to rely on other events that get triggered on the client (e.g. other player leaving must mean that RemoteTable is getting destroyed on the server).

I have decided to add this in 1.2

1 Like

This solution would be perfect for me if a client listener returned the path of the value that was changed as a table, this is provided to me by Replica’s :OnChange(function(action, path))

In my project we have a variety of user data (inventory, unlocks, settings, statistics etc) that can be changed by the server, and for many settings we don’t need any followup but for some we need to apply some unique logic (i.e. changing instances, modifying gameplay mechanics) which we do by having a table of ‘applier functions’ that are indexed by strings that match the key in the table:

playerReplica:OnChange(function(action, path)
	if path[1] == "Settings" then
		if SettingAppliers[path[2]] then
			SettingAppliers[path[2]]()
		end
	end
end)

Unless I’m sorely misunderstanding the documentation here, I don’t see a way to play nicely with this implementation. It would appear that I need to manually listen to every setting, i.e:

RemoteTable.GetSignal(token, "Changed", {"Settings","SomeSettingName"}):Connect(function(new, old)
	-- do something
end)

RemoteTable.GetSignal(token, "Changed", {"Settings","AnotherSetting"}):Connect(function(new, old)
	-- do something
end)

RemoteTable.GetSignal(token, "Changed", {"Settings","AThirdSetting"}):Connect(function(new, old)
	-- do something
end)
-- ...

or do something to the tune of hand-writing the paths for every setting in the table of editable settings:

for setting, data in EditableSettings do
	RemoteTable.GetSignal(token, "Changed", data.Path):Connect(function()
		SettingAppliers[setting]()
	end)
end

Neither of which sits well with me (I’m a gameplay programmer so this is out of my breadth) - if this is inherently a tradeoff for performance then I understand

This feature would be really easy to implement but it’s a real performance drainer since it fires for every change. I advise devs to only listen to data they actually need instead of handling everything in a global OnChange function.

or do something to the tune of hand-writing the paths for every setting in the table of editable settings:

yes this is how you’re supposed to do it in a more performant way.

Also my solution would look like this:

for setting_name, _ in SettingAppliers do
	RemoteTable.GetSignal(token, "Changed", {"Settings", setting_name}):Connect(function(new, old)
		SettingAppliers[setting_name](new, old)
	end)
end

To me this solution is more self contained and easier to code than

playerReplica:OnChange(function(action, path)
	if path[1] == "Settings" then
		if SettingAppliers[path[2]] then
			SettingAppliers[path[2]]()
		end
	end
end)

love this so much, have to switch from replica due to the size of packets.

was wondering if you plan on adding bindtoinstance. its really helpful for objects that stream in and out

1 Like

Im not planning to add bind to instance but I believe you can easily create a wrapper for it, also glad you’re enjoying the library!

not sure if youd rather this on github or on here but i kept getting errors on the promise:resolve function on line 82 in the client because RemoteTables[token] was returning nil

looks like remote tables that exist before the client joins wont get the tokens sent to said clients

adding this seemed to fix it in token registry

would happen if you try to waitfortable on a remotetable that existed before the client joined

if IsClient then
	for name, token in script:GetAttributes() do
		Register(name, token)
	end
	
	TokenRemote.OnClientEvent:Connect(function(command: "A" | "R", token_name: TokenName, token: Token)
		if command == "A" then Register(token_name, token) end
		if command == "R" then Unregister(token_name) end
	end)
end
1 Like

Thank you for the report. This is indeed a bug I will push the latest version with this being fixed!

1 Like

v1.2 is Here!

  • Fixed: Token registry not registering all tokens on initialize. Thanks to @calinpj04
  • Destroying remote table now cleans up everything and releases all references.
  • Improvement to Listener logic
  • Removing a client from server cleans up everything on client
4 Likes

Small Addition to 1.2:

  • .Get now returns the root table of the remote table
1 Like

Hey! Do I have to worry about this?

Can you give me a minimal reproduce file so I can debug it. Thanks!

I should give it a try, I am o1 paranoid too, and now when I enumerated all my data, just found out that replica do not work anymore. Pitifully I missed that disclaimer about it working only with strings…
My only question, if I’ll move from Replica to RemoteTables, should I switch to vanilla remoteevents for pure FireClient, FireServer, FireAllClients events? Or there is some substitution I can use for this?

Thank you for trying the library! Even tho the library is still freshly out I am confident in terms of stability. On top of that you get fast bug fixes because I actively use this library myself.

For the question. You do not need to change anything about your networking setup. RemoteTable-Light creates its own remote event at runtime and only uses that to communicate with the client while writing each message into a buffer to optimize network usage. So, no, you do not need to change anything about how you use remote events.

1 Like

There isn’t proper traceback all the lines come from the module and its packages so I don’t know what exactly causes it specially because it was happening randomly in game.

I can show my RemoteTable set up though.

Thanks for swift reply, I am working on replacing my Replica setup right now, looks promising.
I want to clarify my question:
I was using Replica:FireClient, Replica:FireServer, etc as substitution for default remote events. I used them when I dont need to store data in tables, for example, when I just need to send notification to player from server to client, or when I need to send signal to start construction from client to server. Now after the switch to your library, can I use it to send one-time events, or should I use something else? I see no such options in your description. I can use Reflex for example. But just asking to be sure.
Thanks for your hard work again :slight_smile:

Unfortunately I can not really do anything without a minimal bug reproduce file. The line that’s addressed is a line that works through server authority so it being nil is not a possbility unless something else is going on that I’m not aware of.

It is the line that “creates” a new remote table on the client through a special encoded event sent by the server to only “waiting” clients. So ideally there shouldn’t be any way that this waiting promise is nil of course unless an error on my end. If you could reproduce this bug and send me the test file I can debug it and ship the fix.

Any additional information that could help me reproduce this bug is very much appreciated.

I don’t exactly know why Replica:FireClient or what Replicate:FireServer are but they are certainly using RemoteEvents under the hood. There’s no other way to post information in a freely structured payload otherwise. RemoteEvents and RemoteFunctions are the only way.

So you can definitely use normal remote events or use a remote event wrapper that makes it easier to create new remote events without creating remot events instances everywhere.

Summary

Thank you very much for your reply, again.

I dont want to bother you much, but I feel a bit dumb…

I dont understand how to expand the template with new tables.

Like I have this:

local playerDataTemplate = {
	Money= 0,
	Units = {},
}

I want to add unitData, it has level, xp, hp, etc. I want to send it as array:

RemoteTable.Create(tostring(player.UserId), playerDataTemplate , {})
RemoteTable.Set(playerData.Units, unitId, dataArray)

will it work? Because this is the main reason of me moving out of replica.

  1. unitId - is the number, can I use numbers, or I still need to use strings for path, the same as in replica?
  2. dataArray - as you see I try to insert table as value, can I do it? Or I should set every final value separately in a loop?

This is critical for me - to use numbers for path and numbered arrays. While expanding arrays in a loop and running Set for each value is not an issue, but not having numbered arrays is a big issue, because as I said earlier, all my data is enumerated.

P.S. tests show that it really supports numbered array, yay! the only issue so far is that it doesnt support Instances… I try to send array with instances, but the client gets nothing - empty array. It works in Replica though. Will it change in the future?
ReplicatedStorage.RemoteTableLight.Server:242: Value can not be an Instance.

P.P.S. I checked Packet documentation and it supports Instances. They are pretty small data bits. But it seems you excluded them for a purpose, can you explain why?

1 Like