Client

callbackRegister

fjsf.callbackRegister(name, handler)

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

This allows the server to execute client logic and receive a returned value.


Parameters

  • name string Unique identifier of the callback.

  • handler function Function executed when the callback is triggered by the server. Arguments are forwarded from the server. The returned value is sent back to the server.


Returns

This function does not return anything.


Example

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

callbackCall

Calls a server-side callback asynchronously.

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


Parameters

  • name string Registered server 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 server callback.


Returns

This function does not return anything.


Example


callbackAwait

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

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


Parameters

  • name string Registered server callback name.

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

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


Returns

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


Example

Last updated