Callback Server
A module to use callback module server side
JO Functions
jo.callback.registerCallback()
A function to register a server callback
Syntax
jo.callback.registerCallback(name, cb, latent)Parameters
name : string
The name of the callback event
cb : function
The function executed when the callback is triggered
⚠️sourceis always the first argument
jo.callback.registerLatentCallback()
A function to register a latent server callback
Syntax
jo.callback.registerLatentCallback(name, cb)Parameters
name : string
The name of the callback event
cb : function
The function executed when the callback is triggered
⚠️sourceis always the first argument
jo.callback.triggerClient()
A function to trigger a client callback
Syntax
jo.callback.triggerClient(name, source, cb, ...)Parameters
name : string
The name of the callback event
source : integer
The source of the client to trigger
cb : function Optional
Function to receive the result of the event
... : any Optional
The list of parameters to send to the callback event
Example
local value1 = 5
local value2 = 10
local source = 1
jo.callback.triggerClient('testClientCallback', source, function(returnValue)
print(returnValue)
end, value1, value2)
--OR--
local value1 = 10
local value2 = 5
local returnValue = jo.callback.triggerClient('testClientCallback', source, value1, value2)jo.callback.triggerServer()
A function to trigger a server callback
Syntax
jo.callback.triggerServer(name, cb, ...)Parameters
name : string
Name of the callback event
cb : function Optional
Function to receive the result of the event
... : any Optional
The list of parameters to send to the callback event
Example
local value1 = 5
local value2 = 10
jo.callback.triggerServer('testServerCallback', function(returnValue)
print(returnValue)
end, value1, value2)
--OR--
local value1 = 10
local value2 = 5
local returnValue = jo.callback.triggerServer('testServerCallback', source, value1, value2)