Server

callbackRegister

fjsf.callbackRegister(name, handler)

Registers a server-side callback that can be invoked from clients.

This allows clients to request server logic execution and receive a returned value.


Parameters

  • name string Unique identifier of the callback.

  • handler function Function executed when the callback is triggered by a client. The first argument is the player source. Additional arguments are forwarded from the client. The returned value is sent back to the client.


Returns

This function does not return anything.


Example

fjsf.callbackRegister('ping', function(source)
    return 'pong'
end)

callbackCall

Calls a client-side callback asynchronously.

The provided response function is invoked when the client returns a result or when the timeout is reached.


Parameters

  • target number Player source.

  • name string Registered client callback name.

  • timeout number | nil Maximum wait time in milliseconds. Defaults to 5000 if nil.

  • response function Function invoked with the returned value. Receives nil if the request times out.

  • ... any Arguments passed to the client callback.


Returns

This function does not return anything.


Example


callbackAwait

Calls a client-side callback and waits synchronously for the result.

This function blocks execution until a response is received or the timeout expires.


Parameters

  • target number Player source.

  • name string Registered client callback name.

  • timeout number | nil Maximum wait time in milliseconds. Defaults to 5000 if nil.

  • ... any Arguments passed to the client callback.


Returns

  • any Returned value from the client callback, or nil if the request times out.


Example

Last updated