[ARCHIEVED] FastNet2 - a fast, efficient & lightweight network library

FastNet2 | Update

  • Using Luau Native Code Generation (–!native) for better optimized performance
  • Changed serialize identifier from hash to string.pack (with lower byte cost)
  • Add Util.Session (Internal function) for serialize function
  • Minor fix .CheckUpdate function
  • Other minor change
Version: RC9 (0.9.3)

Available with Standalone .RBXM, .luau files in Github Repo & Wally Package.


FastNet2 - Commit
FastNet2 - Wally

2 Likes

reupdated existing benchmark test result & add another poll

1 Like

NetBench
this netbench for scoring networking module on server/client side, the score is depending to their time and performance affect to frame time (delta).

1 Like

FastNet2 | Patch

  • Fixed Creating twice “Event” Instance
  • Fixed requestId on Client/Server Pull (function)
  • Add .uniqueNum (function) for requestId (Internal function)
  • Minor performance improvement on :Fire (function) at Client-Side
Version: RC9 (0.9.4)

Available with Standalone .RBXM, .luau files in Github Repo & Wally Package.


FastNet2 - Commit
FastNet2 - Wally

1 Like

I’d like to report a situation I had recently with FastNet2 regarding the Pull function.

I needed to invoke the server in order to update the client but I was aware that the answer could possibly return as nil, so I had to add it into a loop. The problem is, the Pull function only requested it once.

-- CLIENT
function Controller:GetServerProfilePromise(Player : Player)
	return Promise.new(function(resolve, reject, onCancel)
		local Profile = DataEvent:Pull(5, "GetProfile", Player) 
		if Profile == nil then
			repeat 
				task.wait(0.5)
				Profile = DataEvent:Pull(5, "GetProfile", Player) 
				print(Profile)
			until Profile ~= nil
		end

		resolve(Profile)
	end)
end

-- SERVER
DataEvent:Connect(function(Player : Player, Action : string, ...)
    local Args = {...}

	if Action == "GetProfile" then
		local Target : Player = Args[1]
		if not Target then warn("Invalid Target: ", Target) return end

		return Service:GetProfile(Target)
	end
end

I solved it by just using a normal RemoteFunction.
If I was using it wrong, please let me know!

Also, I realized that you cannot call the same identifier in two Scripts / LocalScripts, it would error in the debug util.

I found that to be an issue for my use cases, so I did this modification on both the Client and Server modules:

-- CLIENT
function Client.new(Identifier: string)
	Debug.new(typeof(Identifier) == "string", "[FastNet2]: Identifier must be string", 0)
	--Debug.new(not Identifiers.find(Util.ser(Identifier)), string.format("[FastNet2]: %s already exist", Identifier), 0)
	if not Identifiers.find(Util.ser(Identifier)) then
		Process.reg(Util.ser(Identifier))
		Collections[Util.ser(Identifier)] = setmetatable({
			Identifier = Util.ser(Identifier),
			func = function(...: any): (...any) end,
			Connected = false,
			flag = {},
		}, Client)
	end

	return Collections[Util.ser(Identifier)]
end

-- SERVER
function Server.new(Identifier: string)
	Debug.new(typeof(Identifier) == "string", "[FastNet2]: Identifier must be string", 0)
	--Debug.new(not Identifiers.find(Util.ser(Identifier)), string.format("[FastNet2]: %s already exist", Identifier), 0)
	if not Identifiers.find(Util.ser(Identifier)) then
		Process.reg(Util.ser(Identifier))
		Collections[Util.ser(Identifier)] = setmetatable({
			Identifier = Util.ser(Identifier),
			func = function(...: any): (...any) end,
			Connected = false,
			flag = {},
		}, Server)
	end
	
	return Collections[Util.ser(Identifier)]
end

So now in case the identifier is already in use, it just returns it. This might not be compatible with other parts of the module but so far it has worked fine for me. I’d appreciate it if you could turn the possibility to use the same event in multiple scripts a feature!

2 Likes

pulling event is still buggy, im still thinking about it.

hey could u give me a .rbxl file on here or private message for a sample that had same issue (pull function issue), because i tested and seem fine.

if it return nil it supposed to be issue on server side where the client did not receive or it was the client (server sent back to client and received from client but failed to process or something unknown bug) that made the client pull function the timeout being expired and finish it by return nil

I’ll prepare here and send you on private.
Edit: Nvm, I have not been able to replicate it on a particular place, it might have been a particular issue with the game place itself.
I will get in contact if I manage to cause it again.

My GetProfile() function warns whenever the answer is gonna be nil, which is what made me curious on why it was not warning anything server side and still returning nil.

im thinking if it was issued with the wait event being connected (built-in feature) aka wait till player being loaded, i will push patch for that

FastNet2 | Patch

  • Fixed Wait-Event Connected (built-in feature)
  • Support for using multiple :Wait
  • Fixed .new for multiple same-event
Version: RC9 (0.9.5)

Available with Standalone .RBXM, .luau files in Github Repo & Wally Package.


FastNet2 - Commit
FastNet2 - Wally

could u try again with new patch (0.9.5)?

Yes, I’ll do that once I’m able to get on studio!

FastNet2 | Patch

  • Changed :Pull to :Invoke (arguments parameter still the same just the function naming is changed)
  • Improved Invoking on bandwidth saving (only affect to multiple-events)
  • Fix :Once
  • Changed entire .Session works
  • :Invoke now use .Session for it internal system
  • Update Docs for :Invoke
Version: RC9 (0.9.6)

Available with Standalone .RBXM, .luau files in Github Repo & Wally Package.


FastNet2 - Commit
FastNet2 - Wally

2 Likes

Very nice library it helped a LOT with my game.

2 Likes

FastNet2 is currently almost getting stable-release after :Invoke is stabled, if you found/had any issues with :Invoke usage let me know.

3 Likes

any release date for unreliable remoteEvents?

Whats the benefit of using this over BridgeNet or Red?

FastNet2 | Update

  • Add Unreliable Event Support (beta)
-- Example Usage:
-- FastNet2Module.new(Identifier: string, reliable: boolean)
local MyEvent = FastNet2.new("Event1", false) -- so this event will be unreliable
MyEvent:Fire("hello world!") -- sent to server

-- Note: Invoke & Pre Process dont work with Unreliabled Event but u still can use :Invoke with Unreliabled Event but it will use Reliable Functional for it.
Version: RC9 (0.9.7)

Available with Standalone .RBXM, .luau files in Github Repo & Wally Package.


FastNet2 - Wally

1 Like

It seemed to me that the performance on this (based on the Benchmark that is linked in the post) was somewhat better than that of other Nets?

I may be wrong, but I might try this instead of Red if it’s easy to setup.