In RbxNet, there are three categories of remote objects:
- Event - This is analogous to a
RemoteEvent. This is what is used if you want to send an event (like an action) to the server or a player.
- AsyncFunction - This is like a
RemoteFunction, but uses
RemoteEventinternally. The difference with this and
AsyncFunctionwill handle time outs and runs completely asynchronously. (meaning it wont yield code) If there is no response from the reciever, it will reject.
- Function - This is analogous to a
RemoteFunction. However unlike a regular
RemoteFunctionthis does not allow you to call a client. This is for security reasons discussed here
Given the above knowledge, we can then apply that to our remote definition script. There are the following functions under
Net.Definitions for creating definitions for the three categories we have above. The API for each type of definition is explicit so it is easy to understand what each defined remote does.
Net.Definitions.ServerToClientEvent- Defines an event in which the server sends an event to one or many clients
Net.Definitions.ClientToServerEvent- Defines an event in which the client send events to the server
Net.Definitions.BidirectionalEvent- Defines an event in which both the server can send an event to one or many clients, and also the clients can send events to the server. This should only be used in cases where it's required.
Net.Definitions.ServerAsyncFunction- Defines an async function which exists on the server, and can be called by clients. The returned result will be recieved on the client as a promise.
Net.Definitions.ClientAsyncFunction- Defines an async function which exists on the client, and can be called by the server. The returned result will be recieved on the server as a promise.
Net.Definitions.ServerFunction- Defines a synchronous function which exists on the server, and can be called by clients
With the above knowledge, we can create a few example definitions. Say I would like a use case like the following
Straight away you can see it's quite easy to know what remote does what.