ByteNet | Advanced networking library w/ buffer serialization, strict Luau, absurd optimization, and rbxts support. | 0.4.3

Hey @ffrostfall , it looks like the ByteNet Documentation is missing some information that would be useful to have. Also, the latest Github .rbxm release is 5+ months out of date.

This is an amazing library, and making it open-source was an incredible thing of you to do, so thank you! I just want to give some constructive criticism about the docs page to help those who are struggling.

For one, the docs feel incomplete. They don’t contain standard sections for each custom type, like Packet or Namespace. Also, there isn’t any explanation of how the library handles the creation of these types on the server, then replicates them to the client after the client accesses the library. It’s obvious that’s what happens after poking around in the code, but the docs should also specify that.

Some other issues I noticed:

  1. In the ‘definePacket’ section, under the ‘Sending’ heading:
    Docs are missing server send method ‘sendToList’. It only shows 3 send methods for the server, but in the packet’s code it shows ‘sendToList’ as a 4th method for the server.

  2. The docs aren’t very clear on Namespaces.
    The only mention seen is in the ‘definePacket’ section, where you say they are needed, but no more info is given. In the code for namespace definition it’s clear that they’re just encapsulators for packets, but it would nice for the Docs to have a Section about Namespaces, what they are for, why you need them, etc. In that section, an example of using multiple namespaces, each with their own packets (which can have the same name!), would go a long way.

  3. Packet configuration.
    Right now only Reliability types are able to be configured, but there is no code example of how to do this using the API. Again, digging through the code reveals that you need to include ‘reliabilityType’ in the property table passed to the definePacket() function (this is hinted at in the docs). This is could be a lot clearer from the perspective of a user reading the docs for the first time if the docs included a code example.

  4. Some examples are unclear:
    a) ‘definePacket’ section, in the first example script ‘packets.luau’, where you set up a Namespace and Packet, the packet is named “printSomething”. Later in the section in the code examples, it looks like you’re using the packet defined earlier in packets.luau, but confusingly the packet is now called ‘myPacket’.
    b) ‘definePacket’ section example again,

A final issue unrelated to the documentation:
The latest official release on Github is like 5 months out of date. It was last update March 10th, in which time there have been a ton of updates to the source files and a bunch of forks fixing small problems. For people who don’t use NPM or wally, this is rough! Thanks in advance for updating that!

Thanks for making this awesome library!

10 Likes

Hi! Are you able to return values with ByteNet?

Right now there isn’t support for RemoteFunctions, which is what I’m assuming you’re asking about. FFrostfall left that up to us as devs to handle!

The solution is just to send another packet back with data after your first packet requests it.

is this still being maintained? the last commit was a few months ago

2 Likes

I am trying this module and got everything working.
However, when the game was played by more players, this error pops sometimes:
ReplicatedStorage.ByteNet: message=ReplicatedStorage.ByteNet.process.read:40: attempt to index nil with 'reader', trace=ReplicatedStorage.ByteNet.process.read, line 40 ReplicatedStorage.ByteNet.process.client, line 13 - function onClientEvent

Here are my defined packets:
image
image
image
image
image
image

My game uses deferred events signal behaviour, if that can help.
Any chance this can be fixed ?

This is insane, thanks for making this!

I was looking for this too and just found that you can use

local param = definedNamespace.definedPacket.wait()

and it will return the value which was fired on the client once, didnt test using on server tho since its not within my scope atm

I was able to reproduce this problem by not defining the namespaces on the client. What’s likely the culprit is that you’re sending things to the client before the client can define namespaces. The error is because the packet is nil, so adding this below that line in read will stop the error and drop the event.

if not packet then
	break
end

Alternatively (if the event is important), you can wait for a namespace to exist by adding this beneath the while loop:

local packet = ref[buffer.readu8(incomingBuffer, readCursor)]
local tries = 0

while not packet and tries < 5 and game:GetService("RunService"):IsClient() do
	tries += 1
	packet = ref[buffer.readu8(incomingBuffer, readCursor)]

	if not packet then
		task.wait(1)
	end
end

if not packet then
	return warn("[ByteNet] A packet was dropped - no packet/namespace defined")
end

I doubt that this will be fixed for a while.

1 Like

Good remark, that is in fact possible.
I already opted for the first solution until now (drop the packet).

1 Like