Packet - Networking library

There aren’t any error messages and the thread still goes on. I also tried to reduce the amounts of packets firing but still nothing happens. Other events seem to fire fine.



I tried debugging the method.
image

Other events also seem to fire fine expect the ones I listed.
image

Incredible post! I’ve honestly never used packets in my projects before, and I’m new to scripting. The fact that something like this is open sourced with a provided tutorial, you’re doing beautiful things. Keep up the good work Suphi!

how did you define the packets that are not working and what types are you sending?

The packet is defined normally in the same script that had the working the same packet, I’m only using ONE packet, it works normally in other scripts including the same one I’m having issues in, but the snippet I posted refuses to send calls to the client.
The types I’m sending are all strings.

local _clientReplicate = _clientReplicator("_replicateEffects", _clientReplicator.String, {_clientReplicator.Any}) 

if you like you can DM me the project file so I can test it maybe be able to find the problem

How does your library compare to Bytenet : ByteNet | Advanced networking library w/ buffer serialization, strict Luau, absurd optimization, and rbxts support. | 0.4.3 ?

you can find the types for packet here: Suphi-Packet/Packet/Types/init.lua at main · mrchigurh/Suphi-Packet · GitHub

and the types for bytenet here: ByteNet/src/dataTypes at master · ffrostfall/ByteNet · GitHub

in most cases there the same in some cases there not the same here are a few we can compare:


Vector3

Packet

ByteNet


CFrame

Packet

ByteNet
image


instance

Packet
image

ByteNet
image


first thing you might notice is that Packet gives you more choice
you can have a vector3 that uses 6, 9, or 12 bytes where with bytenet there is only 12 byte vector3s
and for cframes packet has options 12, 15, 18 byte cframes where bytnet only has 24 byte cframes

another thing you might notice is that packet support many more types just to show a few


packet also has a very powerful Any type
image


another difference is syntax

Packet

local Packet = require(game.ReplicatedStorage.Packet)

local myPacket = Packet("MyPacket", Packet.String)

myPacket:Fire("Hello")

ByteNet

local ByteNet = require(game.ReplicatedStorage.ByteNet)

local mySpace = ByteNet.defineNamespace("MySpace", function()
	return {
		MyPacket = ByteNet.definePacket({value = ByteNet.string})
	}
end)

mySpace.MyPacket.sendToAll("Hello")

there are more differences but the underlying technique between the 2 is the same both serializes your data into buffers

3 Likes

I tried to at least fix the issue by making another packet for message yet this happened.

@Client
_effectsModule.a4a_packetsMain("_replicateEffectsMessage", _effectsModule.a4a_packetsMain.String, {_effectsModule.a4a_packetsMain.Any}):Connect(function(_effectName: string, ...)
	print(_effectName, ...)
	local _effectName: string = _effectName
	if _effectsModule[_effectName] then
		if type(_effectsModule[_effectName]) == "table" then
			_effectsModule[_effectName][table.unpack(...)]()
			return
		end
		_effectsModule[_effectName](table.unpack(...))
	end
end)

@Server

local _clientReplicator = require("../../../../ReplicatedFirst/_Modules/a4a_packetsMain") 
local _clientReplicate = _clientReplicator("_replicateEffects", _clientReplicator.String, {_clientReplicator.Any})  -- bugged packet that didn't send calls to client
local _clientReplicateMessage = _clientReplicator("_replicateEffectsMessage", _clientReplicator.String, {_clientReplicator.Any})

local _nemesisDialog: string = module._playDialogeNPC(Player, _killedPlayerNPCName)
if _nemesisDialog then
	_clientReplicateMessage:FireClient(_playerEverKilled, "a4a_doMessage", {_nemesisDialog, "nemesis"})
	_clientReplicateMessage:FireClient(Player, "a4a_doMessage", {_nemesisDialog, "killstreak"})
	print(true, 18, _nemesisDialog)
end
_clientReplicateMessage:Fire("a4a_doNemesis", {_generalAllString})

are you its not meant to be

_effectsModule.a4a_packetsMain("_replicateEffectsMessage", _effectsModule.a4a_packetsMain.String, {_effectsModule.a4a_packetsMain.Any}).OnClientEvent:Connect(

other then that i did not notice any other problems

1 Like

Isn’t that just called compression

1 Like

I know this is off topic, but why are you prefixing every variable with an _? To my knowledge you only do that for private table members, or for when you wanna define something without shadowing something else that’s already defined

It’s for this, I define other variables such as services normally while leaving out the rest

1 Like

I dunno, the standard for roblox is that you use camel case for normal/temporary variables, I’ve just never seen it that’s all :V

I fixed that and yet the packet still refuses to send anything to the client, I genuinely don’t know what’s the cause anymore.

maybe we don’t have access or any documentation that I’m aware of that explains what is happening under the hood but we could assume its compression but we don’t know how it works or what type of compression it is

This is a bit off topic but I am pretty sure I saw Float16 for this, in what cases would you want to use float16, wouldn’t it be too imprecise for anything, or am I just stupid.

Oh, yes it was mentioned by WheretIB on the buffer announcement post :+1:

IIRC it internally uses zstd compression.
You can force the compression on a buffer with HttpService:JSONEncode(buffer) and that would give you a base64 encoded result of the compressed buffer.

2 Likes

Noticed an issue with the Signed number format, if the value is negative and then you add the 0.5 the buffer will automatically round it up which can lead to an offset of about +1.

Not a huge deal but for some people who send in directional values that stack on top of eachother it can add up fast

1 Like

nice thanks for sharing I did not read the anoucments of buffers so was not aware

2 Likes

that’s intended behaviour because the value is floored when its converted from a float to a Integer

math.floor(10.5) = 10

math.floor(-10.5) = -10