DirkScripts
Docs
Callback
βΉοΈ Shared - These functions can be used server and client however take note of the direction of callbacks and regration.
Client & Server are able to callback between however you are unable to callback between clients.
#lib.callback.await
βΉοΈ the playerId is only present on the server side, it is not required for the client side.
Call and await for a response of a server callback
lua-- Client lib.callback.await(event, ...) -- Server lib.callback.await(event, playerId, ...)
| Parameter | Type | Required | Description |
|---|---|---|---|
| event | String | true | Server defined event name |
| playerId | Number | true | Server Only - source to send request to |
| cb | Function | true | Callback function, there must be at least one defined |
#lib.callback (async)
Call a callback without blocking the current thread. The response is handled in the provided callback function.
lua-- Client lib.callback(event, cb, ...) -- Server lib.callback(event, playerId, cb, ...)
| Parameter | Type | Required | Description |
|---|---|---|---|
| event | string | yes | Event name of the registered callback |
| playerId | number | yes | Server only β target player source |
| cb | function | yes | Function to receive the response |
| ... | any | no | Additional arguments to pass |
#lib.callback.register
Register a callback handler. This can be used to easily request data from a client from the server, or vice versa
lualib.callback.register(event, cb)
| Parameter | Type | Required | Description |
|---|---|---|---|
| event | String | true | Event name to be called from the server |
| cb | Function | true | Callback function, should return values for the callback |
