Server

Trigger Client Callback

FM.callback.async

Triggers an asynchronized callback to the client, callback will be called upon response from the client.

FM.callback.async(event, source, cb, ...args?)
Argument
Type
Default

event

string

-

source

number

-

cb

function

-

...args?

any

-

FM.callback.async('fm:getValue', 1, function(value)
    FM.console.debug(value) -- output: 'bar'
end, 'foo')

FM.callback.sync

Triggers a synchronized callback to the client, waits for any response from the client.

FM.callback.sync(event, source, ...args?)
Argument
Type
Default

event

string

-

source

number

-

...args?

any

-

local value = FM.callback.sync('fm:getValue', 1, 'foo')
FM.console.debug(value) -- output: 'bar'

Register Server Callback

FM.callback.register

Registers a callback handler on the server that can be triggered from the client.

FM.callback.register(event, cb)
Argument
Type

event

string

cb

function

FM.callback.register('fm:getValue', function(src, value)
    return value == 'foo' and 'bar' or nil
end)

Last updated

Was this helpful?