Connections now spawn a thread, making them yield-safe and error-proof.
Added .WaitForBridge()
Added Roact’s Symbol class- not used for now, will be used for .Start configuration in the future.
.CreateBridge() now has the same functionality of .FromBridge()
Server now checks for the BridgeObject to exist before trying to run connections. If it doesn’t exist, nothing happens.
Friendly reminder, you should be using the latest version of BridgeNet at all times. Not doing so can cause issues with your game / result in errors and buggy behavior. For example, before this update, any error in connections would halt the whole process and prevent other connections on the object from running. It was also not yield-safe. This is fixed now.
I don’t know how you achieved this, but this is amazing. I’m doing the same thing I explained above, firing bridge event from client, and on the server changing waist rotation.
I wanted to test the difference myself, so first I fired 100 remote events without using bridge. My ping was 3k+.
Then I implemented bridge and did the absolute same thing. Literally nothing in the code is changed, except instead of remote events I am using Bridge Events. Firing 100 in a single frame. This is the result:
To clarify, even on an empty baseplate I have 100 ping because I live far from the servers, so firing 100 Bridge Events every frame has basically same toll on performance as an empty baseplate.
TLDR: Magnificent module providing incredible network optimization.
I definitely recommend everyone using this module, as it will allow you to implement much more things in your game without causing massive lags.
@ffrostfall I recommend you create a way to donate to this module voluntarily, I would gladly donate.
1 question: “CreateBridge() now has the same functionality of .FromBridge()”
If I understand correctly, this means that if a bridge is already created, it will get the already created bridge, instead of creating a new one with same string, right? Or should I implement my own logic for that?
Thank you so so much for the feedback! Appreciate the praise a lot, however I do have a tip for you- instead of sending it constantly per heartbeat/whatever, you can cache the value to detect if it’s the same. That way you’re not firing it constantly.
If you’re firing anything else like a string to say “this is rotation”, do it with BridgeNet.CreateIdentifier. It was made specifically to compress strings, and it’ll further optimize your networking.
As per your question, yes. If you create a BridgeObject with .CreateBridge and one already exists, it’ll return that.
This is because it doesn’t make sense to have multiple objects for a single remote. You do not need to implement your own object.
Just a thought, I’ve got no idea how this works but could you make sending the data from the server parallel? It could probably speed it up on the server.
local MineBlock = BridgeNet.CreateBridge("MineBlock")
local UserInputService = game:GetService("UserInputService")
BridgeNet.Start({
[BridgeNet.DefaultReceive] = 60,
[BridgeNet.DefaultSend] = 60,
})
UserInputService.InputBegan:Connect(function(Input, GameProcessed)
if GameProcessed then return; end
if Input.UserInputType == Enum.UserInputType.MouseButton1 or Input.UserInputType == Enum.UserInputType.Touch then
local Target = RbxMouse:GetTarget()
if Target.Instance then
MineBlock:Fire(Target.Instance)
end
end
end)
No errors whatsoever, I have print lines in my actual code for debugging and they all print fine. Is there something I missed?
local BridgeNet = require(game.ReplicatedStorage.BridgeNet)
local Remote1 = BridgeNet.CreateBridge("RemoteEvent1")
script.Parent.MouseButton1Click:Connect(function()
Remote1:Fire("Hello", "this is a test.")
end)
I haven’t got it to work for me yet, and I’m very confused on what I did wrong, but nice module anyways!
Am I doing something wrong? I’m trying to see how it works, before I implement it fully in my game. This will work great with my big game, and save bytes.
Server:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local BridgeNet = require(ReplicatedStorage.BridgeNet)
BridgeNet.Start({
send_default_rate = 60,
receive_default_rate = 60,
})
local Bridge = BridgeNet.CreateBridge("Testing")
Bridge:Fire("hello", "world")
Client:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local BridgeNet = require(ReplicatedStorage.BridgeNet)
BridgeNet.Start({
send_default_rate = 60,
receive_default_rate = 60,
})
BridgeNet.CreateBridge("Testing"):Connect(function()
print("s")
end)
I got it to work finally after experimenting with a couple of things, and the documentation isn’t really clear on how you Fire stuff and retrieve stuff from server to client and client to server, but overall it’s a good module.
This is Client to Server that I figured out, but I don’t know how to do the complete opposite because the functions are not the same as Client to Server.
Client:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local BridgeNet = require(ReplicatedStorage.BridgeNet)
BridgeNet.Start({
send_default_rate = 60,
receive_default_rate = 60,
})
BridgeNet.CreateBridge("Something"):Fire("something")
No it has not, I’m on the latest release and it is saying
18:59:42.231 Players.Bulldo344.PlayerScripts.BNClient:5: table index is nil - BNClient:5
18:59:42.231 Stack Begin
18:59:42.231 Script 'Players.Bulldo344.PlayerScripts.BNClient', Line 5 - BNClient:5
18:59:42.231 Stack End