Bridge
Bridges are the Transport and SerDes Layer of YetAnotherNet, responsible for serializing and deserializing data as well as sending it over the network.
The Bridge class should only be used internally within the Library, when creating behavior identical to hooks, or when performing Unit/Integration Tests.
The Bridge is structured in a way to enable simple mocking using Jest-Lua.
Functions
new
Bridge.
new
(
) →
boolean
This creates a new Bridge and performs initialization work.
You should not create or use Bridges in your code unless creating custom scheduling behavior similar to hooks. If you can use the native Hooks API, it is recommended you do instead of using the Bridge directly.
Creating a new Bridge does not create new Remotes, all Remotes are shared by all Bridges. During Mocking, we can change this behavior by overwriting the Bridge:_getRemotes() method.
_sendPayloads
Bridge:
_sendPayloads
(
) →
(
)
Before sending the Payloads over the network, this method will attempt to serialize the Payloads into buffers. If the payload fails to serialize, it will send the unserialized payload instead.
_processOutgoingQueue
Bridge:
_processOutgoingQueue
(
) →
ClientPayloads,
ServerPayload
This method will process the OutgoingQueue and pack it into Payloads for use in Bride:_sendPayloads()
snapshot
Bridge:
snapshot
(
) →
(
)
Returns a copy of the snapshot. The snapshot is a snapshot of the last frame's IncomingQueue.
beginFrame
Bridge:
beginFrame
(
) →
(
)
The IncomingQueue is a queue that collects all the incoming data from a frame, the use of this function creates a new snapshot of it and then empties the queue. This snapshot is what your Routes will use to read the data that was sent in the last frame.
NOTE
Assuming all scheduling code and the use of send
and query
are running on the Heartbeat,
this will not actually cause any delay for when you recieve your data, as Replication Events are sent
after the Heartbeat.
See Schedular Priority
for more information.
WARNING
You should only use this function if creating custom scheduling behavior similar to the Hooks API, which you should use instead of trying to achieve this behavior using the Bridge itself.
endFrame
Bridge:
endFrame
(
) →
(
)
The OutgoingQueue collects all the outgoing data from a frame, when you do
Route:send()
the data is not immediately sent over the network, it is instead
batched and sent over the network at the end of the frame.
NOTE
Assuming all scheduling code and the use of send
and query
are running on the Heartbeat,
this will not actually cause any delay for when you recieve your data, as Replication Events are sent
after the Heartbeat.
See Schedular Priority
for more information.
WARNING
You should only use this function if creating custom scheduling behavior similar to the Hooks API, which you should use instead of trying to achieve this behavior using the Bridge itself.