한국어 👈
ByteNet fork made more handy
- HandyNet is a fork of ByteNet and shares most of its implementation.
- The code design and ideas are derived from
kitty-utils/net.
pesde add caveful_games/handynet- (From
v0.3.0) Don't have to write a function when defining namespace. - (From
v0.2.0) Due to the dynamic typing ofHandyNet.send, it can theoretically be slightly slower thanByteNet.sendToandByteNet.sendToAllon the server. (It is more simple and more type-safe and removes the need forNamespace.serverandNamespace.client, except in cases where the player argument is used on the client.) - (From
v0.2.0)Packets are one directional. - (From
v0.2.1) Packet definitions can be nested for labeling purpose. - Resizable
ByteNet.stringdata type. - Simplified
definePacketAPI. - Some data type names have been made clearer.
Added(Replaced byCommand, which is handier for designing a client/server synchronization model.events)- Events and connections are handled by
LimeSignalwhich is fork ofLemonSignal. (Simple event handling method) - HandyNet does not support TypeScript.
- New serdes for
CFrame. - New data types:
RawCFrame(equal toByteNet.cframe),CFrame(uses Quaternion to compress into 13~19 bytes),AlignedCFrame,UnalignedCFrame,Enum, andBrickColor
-- packets.luau
return HandyNet.defineNamespace("example", {
hello = HandyNet.definePacket(
"client->server",
HandyNet.struct({
message = HandyNet.string(HandyNet.u8), -- Customizable string size (defaults to u16)
cf = HandyNet.CFrame, -- Uses quaternion to compress!
enum = HandyNet.Enum.KeyCode :: Enum.KeyCode -- Weird type error with enums..
})
-- default: "reliable"
),
countUp = HandyNet.defineEvent("unreliable")
})-- shared.luau
local packets = require(path.to.packets)
local counts = {}
local function countUp(player)
local count = counts[player]
if not count then
count = 0
counts[player] = count
end
count += 1
counts[player] = count
print("count:", count)
end
packets.countUp.connect(countUp)
return {}-- client.luau
local packets = require(path.to.packets)
packets.hello.send({
message = "hi ya",
cf = CFrame.new(),
enum = Enum.KeyCode.X
})
packets.countUp.fire()-- server.luau
local packets = require(path.to.packets)
-- packets.some.send(data, player)
-- if you want 'sendToAll': packets.some.send(data)
packets.hello.event:connect(function()
print("received hello from client")
end)
packets.countUp.connect(function()
print("client has fired countUp event!")
end)- ByteNet for original source codes. (licensed under MIT license)
- Special thanks to Mark-Marks for major feedbacks.
- Special thanks to roasted_shrimps for new CFrame serdes idea.
- Fix dependencies require error.
- Change
math.sqrtinto^.5(Slightly faster) - Simplify the
defineNamespace(Breaking change)