NettyClient
NettyClient is the client module for the Netty framework. It is used to handle all forms of inbound and outbound traffic. NettyClient serializes any data it can into buffers. Due to the nature of how Netty sends remote data, this approach to networking results in a significant decrease in outbound and inbound traffic, as well as lowering ping.
Functions
Start
NettyClient.
Start
(
) →
(
)
This function starts the network inbound and outbound handler. Additionally, once NettyClient is started, you can begin to send and receive data to and from the server.
RegisterEvent
NettyClient.
RegisterEvent
(
id:
any
,
--
The event id to bind to.
callback:
(
...any
)
→
nil
--
The callback function to run when this event is triggered.
) →
(
)
This function registers an event locally. This is used when the server wants to send data to the client. Events can only have one callback.
info
Events also need to be registered on the server, even if they have no callback. Since Netty uses an identity based system, the client and server need to share event ids.
SpawnEvent
NettyClient.
SpawnEvent
(
eventType:
any
,
--
The event id to trigger.
...:
any
--
The arguments to pass to the event.
) →
(
)
This function spawns an event in the current thread.
note
This function is mainly used internally, so it doesn't offer much configuration / outside influence.
FireServer
NettyClient.
FireServer
(
eventId:
any
,
--
The event id to trigger.
...:
any
--
The arguments to pass to the server.
) →
(
)
This function fires a reliable remote event with proper data serialization to the server.
note
Events aren't fire instantly. They're queued into an outbound pool, and a maximum of 255 events of each type(unreliable, reliable) are fired to the server at once per Heartbeat (RunService.Heartbeat). This function supports all data types, even if they aren't able to be serialized into buffers. Example:
local NettyClient = require(game:GetService("ReplicatedStorage"):WaitForChild("Commons")).Netty.Client
NettyClient.Start()
NettyClient.FireServer("my event", 123, CFrame.identity,"abc", workspace.MyPart) -- All of these arguments will be passed to the server.
FireServerUnreliable
NettyClient.
FireServerUnreliable
(
eventId:
any
,
--
The event id to trigger.
...:
any
--
The arguments to pass to the server.
) →
(
)
This function fires an unreliable remote event with proper data serialization to the server.
note
Events aren't fire instantly. They're queued into an outbound pool, and a maximum of 255 events of each type(unreliable, reliable) are fired to the server at once per Heartbeat (RunService.Heartbeat). This function supports all data types, even if they aren't able to be serialized into buffers. Example:
local NettyClient = require(game:GetService("ReplicatedStorage"):WaitForChild("Commons")).Netty.Client
NettyClient.Start()
NettyClient.FireServerUnreliable("my event", 123, CFrame.identity,"abc", workspace.MyPart) -- All of these arguments will be passed to the server.