X Bridge v4 - Easy Client to Server communication

X Bridge is a fairly simple system that I find myself using a lot.

It allows you to funnel client-server communication through a single RemoteFunction.

Pros

  • Code is more legible
  • Faster developing

Cons

  • X Bridge does not support RemoteEvents
    If you want to squeeze out that extra performance, you can always manually make RemoteEvents. If this module gets popular, I might add something for this in the future

So how does it work?

I’m glad you asked.

X Bridge consists of two modules.
One module for the server side and one module for the client side.

The server side module returns a function formatted like this
ServerSide(array table_of_functions)

The functions inside the array should be formatted like this
table_of_functions.name_of_function = function(player caller_player, variable1, variable2, variable3, etc.)

The client side module returns a function formatted like this
ClientAccess(string name_of_function, variable1, variable2, variable3, etc.)

Usage

In a server script, you can do something like this:

-- Server Script
GiveClientAccess = require(game.ServerStorage.ServerSide)

insecureFunctions = {
	test = function(Player,Brick_Color)
		
		Brick_Color = Brick_Color or BrickColor.Black()
		
		print(Player.Name..' wants to spam '..tostring(Brick_Color)..' parts!')
		
		spawn(function()
			while wait(.25) do
				Instance.new('Part',workspace).BrickColor = Brick_Color
			end
		end)
		
		return true
	
	end,

	something = function(Player,Brick_Color)
		
		print('I do something too!')
		
		return 'pineapples'
	
	end
}

GiveClientAccess(insecureFunctions)

Once you have done that, you can call this function through the client side by doing something like this:

-- LocalScript
RequestServerFunction = require(game.ReplicatedStorage.ClientAccess)

firstRequest = RequestServerFunction('test')

print('First request returned',firstRequest)

secondRequest = RequestServerFunction('test',BrickColor.Red())

print('Second request returned',secondRequest)

anotherRequest = RequestServerFunction('something')

print('I would like '..anotherRequest)

Writing code this way makes it very intelligible.
Gone are the days of messing around with RemoteFunctions!

Feel free to reply with any critiques or suggestions.

PLANNED:

  • Better Network Efficiency
  • Server to Client communication
  • Rate limit feature
6 Likes

Interesting!
I like the simplicity of this system, maybe I may even use this!

1 critique though, it’d be nice if there were functions for Server → Client communication.

3 Likes

Hi there~ @dispeller

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

yes, i should remember to do that more often
Untitled

Server side script:
https://pastebin.com/raw/WiJkCeDe

Client side script:
https://pastebin.com/raw/wHt0NKNQ

Example server script: https://pastebin.com/raw/fVqi4UzA
Example local script: https://pastebin.com/raw/uHKvhHx1


It’s worth noting that I plan on making a v5 with better network efficiency.
As of right now, function names take up some network latency. This is because you’re sending the entire function name through the network.
The future version will either:
A. Automatically translate names to numbers to reduce latency
B. Create a new remote function for every function and allow default Roblox stuff to optimize this for me

1 Like