Javascript Message
(→Constructor) |
|||
(34 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
Yate Message object | Yate Message object | ||
+ | |||
+ | |||
+ | Singleton functions (installSingleton,uninstallSingleton,handlersSingleton,installPostHookSingleton,posthooksSingleton) are not available in: | ||
+ | * Singleton contexts (when a singleton message is handled): handler or post hook<br/> | ||
+ | * Temporary scripts (executed using the ''javascript eval'' command)<br/> | ||
+ | * Script instance greater than 1 for scripts configured with multiple instances. These functions are available in first instance only<br/> | ||
+ | * Routing script configured in javascript.conf | ||
+ | |||
+ | |||
+ | Multiple handlers and post hooks may be installed for the same message using same or different callback, priority, filter.<br> | ||
+ | Multiple handlers and post hooks may be installed for different messages using same callback.<br> | ||
+ | |||
+ | |||
== Constructor == | == Constructor == | ||
* '''new Message(name)''' | * '''new Message(name)''' | ||
− | * '''new Message(name,broadcast)''' | + | * '''new Message(name,broadcast,obj)''' |
Parameters:<br/> | Parameters:<br/> | ||
'''name''' - Name of the message to create (mandatory)<br/> | '''name''' - Name of the message to create (mandatory)<br/> | ||
− | '''broadcast''' - Optional boolean flag to create a broadcast message | + | '''broadcast''' - Optional boolean flag to create a broadcast message<br/> |
+ | '''obj''' - Optional object from which to copy properties as message parameters. Objects, null and undefined values are not copied. | ||
+ | |||
== Static Methods == | == Static Methods == | ||
− | * '''Message.install()''' | + | * '''Message.install(func,name[,priority[,filterName[,filterValue[,params]]])''' |
+ | Install a Yate message handler.<br/> | ||
+ | Parameters:<br/> | ||
+ | '''func''' - Function to be called when a message is received.<br/> | ||
+ | '''name''' - Message name.<br/> | ||
+ | '''priority''' - Message handler priority (integer). Must be at least 0. Defaults to 100 if not given.<br/> | ||
+ | '''filterName''' - Message handler parameter filter name. May be a MatchingItem object containing message parameter(s) matching (''filterValue'' will be ignored). <br/> | ||
+ | '''filterValue''' - Message handler parameter filter value. Simple data (not object) or RegExp.<br/> | ||
+ | '''params''' - Handler parameters (object).<br/> | ||
+ | Return: true on success, false on failure. | ||
+ | |||
+ | Callback: '''function some_function_name(msg[,id])'''<br> | ||
+ | Parameters:<br/> | ||
+ | '''msg''' - Message to be handled.<br/> | ||
+ | '''id''' - Non empty handler id if set on install.<br/> | ||
+ | |||
+ | |||
+ | Handler parameters (set in '''params'''):<br> | ||
+ | '''id''' - Optional handler id (string). Install of a message handler with the same (non empty) value will replace an existing one.<br/> | ||
+ | |||
+ | |||
+ | * '''Message.installSingleton(func,handlerContext,name[,priority[,filterName[,filterValue[,params]]])''' | ||
+ | Install a Yate message handler.<br/> | ||
+ | Callback function will be called using a separate script context (data) for each handled message.<br/> | ||
+ | The context will be deleted after message handling returns.<br/> | ||
+ | Calling this function will replace an existing handler with the same ''handlerContext'' value regardless message name.<br> | ||
+ | Parameters:<br/> | ||
+ | '''func''' - Function to be called when a message is received.<br/> | ||
+ | '''handlerContext''' - Handler context (string). Wiil be passed as second parameter to callback function.<br/> | ||
+ | '''name''' - Message name.<br/> | ||
+ | '''priority''' - Message handler priority (integer). Must be at least 0. Defaults to 100 if not given.<br/> | ||
+ | '''filterName''' - Message handler parameter filter name. May be a [[Javascript MatchingItem|MatchingItem]] object containing message parameter(s) matching (''filterValue'' will be ignored).<br/> | ||
+ | '''filterValue''' - Message handler parameter filter value. Simple data (not object) or RegExp.<br/> | ||
+ | '''params''' - Handler parameters (object).<br/> | ||
+ | Return: true on success, false on failure. | ||
+ | |||
+ | Callback: '''function some_function_name(msg,handlerContext)'''<br> | ||
+ | Parameters: | ||
+ | * '''msg''' - Message to handle.<br/> | ||
+ | * '''handlerContext''' - Singleton context (string) set on install.<br/> | ||
+ | |||
+ | Handler parameters (set in '''params'''): | ||
+ | * '''load_extensions''' - boolean. Load extensions (external, non native, objects) into script context.<br/>Not loading extensions may lead to a faster processing.<br/>Extensions are never loaded if message name matches ''script.init''.<br/> | ||
+ | |||
+ | |||
+ | * '''Message.installPostHook(func,id[,filterMsg[,filterName[,filterValue[,params]]]])''' | ||
+ | * '''Message.installPostHookSingleton(func,id[,filterMsg[,filterName[,filterValue[,params]]]])''' | ||
+ | Install a Yate message post hook handler.<br/> | ||
+ | Post hook handlers are called after a message is dispatched before returning to entity dispatching the message.<br/> | ||
+ | Message object is read only (frozen), can't be changed, you can only read its parameters.<br/> | ||
+ | Singleton: Callback function will be called using a separate script context (data) for each handled message. The context will be deleted after message handling returns.<br/> | ||
+ | The module maintains a single list of post hooks. Installing a post hook with a given id will replace an existing one (singleton or not).<br/> | ||
+ | |||
+ | Parameters:<br/> | ||
+ | '''func''' - Function to be called when a message is handled.<br/> | ||
+ | '''id''' - Handler context (string). Will be passed as second parameter to callback function.<br/> | ||
+ | '''filterMsg''' - Optional message name match. May be a string, RegExp or [[Javascript MatchingItem|MatchingItem]] object.<br/> | ||
+ | '''filterName''' - Message parameter filter name. May be a [[Javascript MatchingItem|MatchingItem]] object containing message parameter(s) matching (''filterValue'' will be ignored).<br/> | ||
+ | '''filterValue''' - Message parameter filter value. Simple data (not object) or RegExp.<br/> | ||
+ | '''params''' - Parameters (object) | ||
+ | Return: true on success, false on failure. | ||
+ | |||
+ | Callback: '''function some_function_name(msg,handled,id)'''<br> | ||
+ | Parameters: | ||
+ | * '''msg''' - Message. Object is frozen.<br/> | ||
+ | * '''handled''' - True if message was handled, false otherwise.<br/> | ||
+ | * '''id''' - Post hook id (string) set in install.<br/> | ||
+ | |||
+ | Post hook parameters (passed in '''params'''): | ||
+ | * '''load_extensions''' - boolean. Load extensions (external, non native, objects) into script context.<br/>Not loading extensions may lead to a faster processing.<br/>Extensions are never loaded if message name matches ''script.init''.<br/> | ||
+ | * '''engine.timer''' - boolean. Process ''engine.timer'' message.<br/>Default to false if ''filterMsg'' is set (assume engine.timer match is set there if desired).<br/> | ||
+ | * '''handled''' - boolean. Callback function call based on message handled value (callback function will not be called if value of this parameter is not the same as meesage handled value).<br/>Default if missing or empty: always call the given callback.<br/>This parameter is ignored for broadcasted messages.<br/> | ||
* '''Message.uninstall()''' | * '''Message.uninstall()''' | ||
+ | Uninstall all message handler(s) including singleton(s).<br> | ||
+ | |||
+ | |||
+ | * '''Message.uninstall(nameOrId[,byId])''' | ||
+ | Uninstall a regular (non singleton) message handler.<br> | ||
+ | Parameters: | ||
+ | * '''nameOrId''' - String. Value used to match the handler.<br/> | ||
+ | * '''byId''' - Boolean. Match by handler id (true) or name (false). Default: false.<br/> | ||
+ | |||
+ | |||
+ | * '''Message.uninstallSingleton(id)''' | ||
+ | Uninstall a singleton message handler.<br> | ||
+ | Parameters: | ||
+ | * '''id''' - Id of message to uninstall (string).<br/> | ||
+ | |||
+ | |||
+ | * '''Message.uninstallPostHook(id)''' | ||
+ | Uninstall a message post hook.<br> | ||
+ | Parameters: | ||
+ | * '''id''' - Id of post hook to uninstall (string).<br/> | ||
− | * '''Message.handlers()''' | + | * '''Message.handlers([match])''' |
− | * '''Message. | + | * '''Message.handlersSingleton([match])''' |
+ | * '''Message.posthooks()''' | ||
+ | * '''Message.posthooksSingleton()''' | ||
+ | Retrieve installed message handlers or post hooks. | ||
Parameters:<br/> | Parameters:<br/> | ||
− | '''match''' - Optional string or RegExp used to match only some handler names<br/> | + | '''match''' - Optional string or RegExp used to match only some handler message names<br/> |
Return:<br/> | Return:<br/> | ||
− | Array of objects describing installed handlers, '''null''' if no handler matches. | + | Array of objects describing installed handlers, '''null''' if no handler matches or no handler installed.<br> |
− | * ''name'' - | + | Object properties:<br> |
− | * ''priority'' - Integer priority of the installed handler | + | * ''name'' - Handler only. Name of the handled message (string).<br> |
− | * '' | + | * ''priority'' - Handler only. Integer priority of the installed handler.<br> |
− | * '' | + | * ''msg_filter'' - Post hook only: message name match. Object. Properties: see see [[Javascript MatchingItem|MatchingItem]].getDesc().<br> |
− | * '' | + | * ''filter'' - Message parameter(s) match. Object. Properties: see [[Javascript MatchingItem|MatchingItem]].getDesc().<br> |
− | * ''trackName'' - | + | * ''handler'' - Name of the handling function (string).<br> |
+ | * ''trackName'' - Handler only. Name of the handler used in tracking (only if not empty). Format: track_name[:priority].<br> | ||
+ | * ''message_context'' - Singleton handler only: handler context.<br> | ||
+ | * ''id'' - Handler/PostHook id (string). Singleton handler: same as message context. Regular (non singleton) handler: present if given on install.<br> | ||
+ | * ''handled'' - PostHook only (boolean). Message handled filter state. Present if set on install.<br> | ||
Line 38: | Line 151: | ||
* '''Message.trackName()''' | * '''Message.trackName()''' | ||
+ | Return:<br/> | ||
+ | Message handler(s) track name value | ||
+ | |||
+ | * '''Message.trackName(name[,trackPrio])''' | ||
+ | Parameters:<br/> | ||
+ | '''name''' - Message track name to be set in new message handlers<br/> | ||
+ | '''trackPrio''' - Add handler priority to track name. Default: true<br/> | ||
== Methods == | == Methods == | ||
− | * '''enqueue()''' | + | * '''enqueue([callback[,params,callback_args...]])''' |
Enqueues the Message in the Yate engine<br/> | Enqueues the Message in the Yate engine<br/> | ||
− | Return: True if enqueue succeeded, false on failure | + | Parameters:<br/> |
+ | '''callback''' - Optional function to be called after message is dispatched. Function is called before passing the message to internal message post hook(s). Function won't be called if enqueue() fails<br/> | ||
+ | '''params''' - Parameter reserved for future use<br/> | ||
+ | '''callback_args''' - Optional parameters to be passed to callback function<br/> | ||
+ | Return: True if enqueue succeeded, false on failure. | ||
+ | '''NOTE: Message object will become invalid after enqueued. Subsequent functions call will fail or raise a runtime error.''' | ||
− | + | Callback: '''function some_func_name(msg,handled[,callback_args...])'''<br/> | |
− | * '''dispatch(unblock)''' | + | Parameters:<br/> |
+ | '''msg''' - Enqueued message. Parameters may change during dispatch<br/> | ||
+ | '''handled''' - Boolean indicating message was accepted (handled) or not<br/> | ||
+ | '''parameters''' - Optional parameters passed on enqueue() function call<br/> | ||
+ | |||
+ | Enqueue parameters (set in '''params'''): | ||
+ | * '''handled''' - boolean. Callback function call based on message handled value (callback function will not be called if value of this parameter is not the same as meesage handled value).<br/>Default if missing or empty: always call the given callback.<br/>This parameter is ignored for broadcasted messages.<br/> | ||
+ | |||
+ | |||
+ | |||
+ | * '''dispatch([unblock])''' | ||
Parameters:<br/> | Parameters:<br/> | ||
'''unblock''' - Optional boolean flag to unblock context variables during dispatch<br/> | '''unblock''' - Optional boolean flag to unblock context variables during dispatch<br/> | ||
Return: True if message was handled, false if it was not handled | Return: True if message was handled, false if it was not handled | ||
+ | |||
+ | '''NOTES on message dispatch without unblocking the context:'''<br/> | ||
+ | # Will prevent script processing of other callbacks: message handling, timer callbacks | ||
+ | # Leads to deadlock if script have a handler for the dispatched message | ||
+ | # Script unload will wait until context is unblocked | ||
+ | |||
Line 60: | Line 201: | ||
* '''broadcast()''' | * '''broadcast()''' | ||
Return: Boolean broadcast flag | Return: Boolean broadcast flag | ||
+ | |||
+ | |||
+ | * '''getParam(name)''' | ||
+ | * '''getParam(name,defValue)''' | ||
+ | * '''getParam(name,defValue,autoNumber)''' | ||
+ | Parameters:<br/> | ||
+ | '''name''' - Name of the parameter to retrieve<br/> | ||
+ | '''defValue''' - Value to return if parameter is missing, default '''undefined'''<br/> | ||
+ | '''autoNumber''' - Automatically convert parameters to boolean or number type, default '''true'''<br/> | ||
+ | Return: Value of parameter, even if name matches a method name | ||
+ | |||
+ | |||
+ | * '''setParam(name,value)''' | ||
+ | Parameters:<br/> | ||
+ | '''name''' - Name of the parameter to set<br/> | ||
+ | '''value''' - New value to set in parameter, '''undefined''' to delete the parameter<br/> | ||
+ | Return: True on success, false if message was not in a state where parameters can be changed | ||
+ | |||
+ | |||
+ | * '''clearParam(name[,sep)''' | ||
+ | Parameters:<br/> | ||
+ | '''name''' - Name of the parameter to clear<br/> | ||
+ | '''sep''' - Optional name separator (first character only)<br/> | ||
+ | Return: True on success, false if message was not in a state where parameters can be changed, undefined if name is not given | ||
+ | |||
+ | |||
+ | * '''copyParams(obj,prefix,skip)''' | ||
+ | Parameters:<br/> | ||
+ | '''obj''' - object from which to copy properties (except objects, null and undefined)<br/> | ||
+ | '''prefix''' - optional parameter to specify that only properties that a key with the given index should be copied. If the prefix represents an object, the properties of that object will be copied.<br/> | ||
+ | '''skip''' - optional parameter (assumed, by default, to be true) to specifies if the prefix should be copied or eliminated from the key being copied. | ||
Line 72: | Line 244: | ||
* '''msgTime()''' | * '''msgTime()''' | ||
− | Return: Message creation time in milliseconds since EPOCH | + | Return: Message creation time in milliseconds since EPOCH, null if message is not valid |
− | * ''' | + | * '''msgTime(value)''' |
+ | Parameters:<br/> | ||
+ | '''value''' - Message creation time in milliseconds since EPOCH. Boolean true to set current time<br/> | ||
+ | Return: True if message creation time changed, false otherwise | ||
− | * '''getRow()''' | + | * '''msgAge()''' |
+ | Return: Message age in milliseconds | ||
+ | |||
+ | |||
+ | * '''getColumn([indexOrName])''' | ||
+ | Retrieve one or all columns from message user data table.<br/> | ||
+ | Message user data is set after a database query. Database query result contains field names and query result data (values).<br/> | ||
+ | Parameters:<br/> | ||
+ | '''indexOrName''' - Optional column numeric index or name<br/> | ||
+ | Return:<br/> | ||
+ | '''null''' if given column index or name is not found or result set is empty<br/> | ||
+ | Column given: array with column values<br/> | ||
+ | Otherwise: Object with all result set data. Object property names are set to field names. Object property values are array with column values.<br/> | ||
+ | |||
+ | |||
+ | * '''getRow([index])''' | ||
+ | Retrieve one or all rows from message user data table.<br/> | ||
+ | Message user data is set after a database query. Database query result contains field names and query result data (values).<br/> | ||
+ | Parameters:<br/> | ||
+ | '''index''' - Optional row numeric index<br/> | ||
+ | Return:<br/> | ||
+ | '''null''' if given row index is not found or result set is empty<br/> | ||
+ | Row given: Object. Object property names are set to field names. Object property values are field values.<br/> | ||
+ | Otherwise: Array of objects. Each object is a row.<br/> | ||
+ | |||
+ | |||
+ | * '''getResult(rowIndex,columnIndexOrName)''' | ||
+ | Retrieve a value from message user data table.<br/> | ||
+ | Message user data is set after a database query. Database query result contains field names and query result data (values).<br/> | ||
+ | Parameters:<br/> | ||
+ | '''rowIndex''' - Row numeric index<br/> | ||
+ | '''columnIndexOrName''' - Column numeric index or name<br/> | ||
+ | Return:<br/> | ||
+ | Found value or '''null''' if cell given by row/column is not found or result set is empty<br/> | ||
− | + | [[Category:Javascript]] |
Latest revision as of 10:40, 10 September 2024
Yate Message object
Singleton functions (installSingleton,uninstallSingleton,handlersSingleton,installPostHookSingleton,posthooksSingleton) are not available in:
- Singleton contexts (when a singleton message is handled): handler or post hook
- Temporary scripts (executed using the javascript eval command)
- Script instance greater than 1 for scripts configured with multiple instances. These functions are available in first instance only
- Routing script configured in javascript.conf
Multiple handlers and post hooks may be installed for the same message using same or different callback, priority, filter.
Multiple handlers and post hooks may be installed for different messages using same callback.
[edit] Constructor
- new Message(name)
- new Message(name,broadcast,obj)
Parameters:
name - Name of the message to create (mandatory)
broadcast - Optional boolean flag to create a broadcast message
obj - Optional object from which to copy properties as message parameters. Objects, null and undefined values are not copied.
[edit] Static Methods
- Message.install(func,name[,priority[,filterName[,filterValue[,params]]])
Install a Yate message handler.
Parameters:
func - Function to be called when a message is received.
name - Message name.
priority - Message handler priority (integer). Must be at least 0. Defaults to 100 if not given.
filterName - Message handler parameter filter name. May be a MatchingItem object containing message parameter(s) matching (filterValue will be ignored).
filterValue - Message handler parameter filter value. Simple data (not object) or RegExp.
params - Handler parameters (object).
Return: true on success, false on failure.
Callback: function some_function_name(msg[,id])
Parameters:
msg - Message to be handled.
id - Non empty handler id if set on install.
Handler parameters (set in params):
id - Optional handler id (string). Install of a message handler with the same (non empty) value will replace an existing one.
- Message.installSingleton(func,handlerContext,name[,priority[,filterName[,filterValue[,params]]])
Install a Yate message handler.
Callback function will be called using a separate script context (data) for each handled message.
The context will be deleted after message handling returns.
Calling this function will replace an existing handler with the same handlerContext value regardless message name.
Parameters:
func - Function to be called when a message is received.
handlerContext - Handler context (string). Wiil be passed as second parameter to callback function.
name - Message name.
priority - Message handler priority (integer). Must be at least 0. Defaults to 100 if not given.
filterName - Message handler parameter filter name. May be a MatchingItem object containing message parameter(s) matching (filterValue will be ignored).
filterValue - Message handler parameter filter value. Simple data (not object) or RegExp.
params - Handler parameters (object).
Return: true on success, false on failure.
Callback: function some_function_name(msg,handlerContext)
Parameters:
- msg - Message to handle.
- handlerContext - Singleton context (string) set on install.
Handler parameters (set in params):
- load_extensions - boolean. Load extensions (external, non native, objects) into script context.
Not loading extensions may lead to a faster processing.
Extensions are never loaded if message name matches script.init.
- Message.installPostHook(func,id[,filterMsg[,filterName[,filterValue[,params]]]])
- Message.installPostHookSingleton(func,id[,filterMsg[,filterName[,filterValue[,params]]]])
Install a Yate message post hook handler.
Post hook handlers are called after a message is dispatched before returning to entity dispatching the message.
Message object is read only (frozen), can't be changed, you can only read its parameters.
Singleton: Callback function will be called using a separate script context (data) for each handled message. The context will be deleted after message handling returns.
The module maintains a single list of post hooks. Installing a post hook with a given id will replace an existing one (singleton or not).
Parameters:
func - Function to be called when a message is handled.
id - Handler context (string). Will be passed as second parameter to callback function.
filterMsg - Optional message name match. May be a string, RegExp or MatchingItem object.
filterName - Message parameter filter name. May be a MatchingItem object containing message parameter(s) matching (filterValue will be ignored).
filterValue - Message parameter filter value. Simple data (not object) or RegExp.
params - Parameters (object)
Return: true on success, false on failure.
Callback: function some_function_name(msg,handled,id)
Parameters:
- msg - Message. Object is frozen.
- handled - True if message was handled, false otherwise.
- id - Post hook id (string) set in install.
Post hook parameters (passed in params):
- load_extensions - boolean. Load extensions (external, non native, objects) into script context.
Not loading extensions may lead to a faster processing.
Extensions are never loaded if message name matches script.init.
- engine.timer - boolean. Process engine.timer message.
Default to false if filterMsg is set (assume engine.timer match is set there if desired).
- handled - boolean. Callback function call based on message handled value (callback function will not be called if value of this parameter is not the same as meesage handled value).
Default if missing or empty: always call the given callback.
This parameter is ignored for broadcasted messages.
- Message.uninstall()
Uninstall all message handler(s) including singleton(s).
- Message.uninstall(nameOrId[,byId])
Uninstall a regular (non singleton) message handler.
Parameters:
- nameOrId - String. Value used to match the handler.
- byId - Boolean. Match by handler id (true) or name (false). Default: false.
- Message.uninstallSingleton(id)
Uninstall a singleton message handler.
Parameters:
- id - Id of message to uninstall (string).
- Message.uninstallPostHook(id)
Uninstall a message post hook.
Parameters:
- id - Id of post hook to uninstall (string).
- Message.handlers([match])
- Message.handlersSingleton([match])
- Message.posthooks()
- Message.posthooksSingleton()
Retrieve installed message handlers or post hooks.
Parameters:
match - Optional string or RegExp used to match only some handler message names
Return:
Array of objects describing installed handlers, null if no handler matches or no handler installed.
Object properties:
- name - Handler only. Name of the handled message (string).
- priority - Handler only. Integer priority of the installed handler.
- msg_filter - Post hook only: message name match. Object. Properties: see see MatchingItem.getDesc().
- filter - Message parameter(s) match. Object. Properties: see MatchingItem.getDesc().
- handler - Name of the handling function (string).
- trackName - Handler only. Name of the handler used in tracking (only if not empty). Format: track_name[:priority].
- message_context - Singleton handler only: handler context.
- id - Handler/PostHook id (string). Singleton handler: same as message context. Regular (non singleton) handler: present if given on install.
- handled - PostHook only (boolean). Message handled filter state. Present if set on install.
- Message.installHook()
- Message.uninstallHook()
- Message.trackName()
Return:
Message handler(s) track name value
- Message.trackName(name[,trackPrio])
Parameters:
name - Message track name to be set in new message handlers
trackPrio - Add handler priority to track name. Default: true
[edit] Methods
- enqueue([callback[,params,callback_args...]])
Enqueues the Message in the Yate engine
Parameters:
callback - Optional function to be called after message is dispatched. Function is called before passing the message to internal message post hook(s). Function won't be called if enqueue() fails
params - Parameter reserved for future use
callback_args - Optional parameters to be passed to callback function
Return: True if enqueue succeeded, false on failure.
NOTE: Message object will become invalid after enqueued. Subsequent functions call will fail or raise a runtime error.
Callback: function some_func_name(msg,handled[,callback_args...])
Parameters:
msg - Enqueued message. Parameters may change during dispatch
handled - Boolean indicating message was accepted (handled) or not
parameters - Optional parameters passed on enqueue() function call
Enqueue parameters (set in params):
- handled - boolean. Callback function call based on message handled value (callback function will not be called if value of this parameter is not the same as meesage handled value).
Default if missing or empty: always call the given callback.
This parameter is ignored for broadcasted messages.
- dispatch([unblock])
Parameters:
unblock - Optional boolean flag to unblock context variables during dispatch
Return: True if message was handled, false if it was not handled
NOTES on message dispatch without unblocking the context:
- Will prevent script processing of other callbacks: message handling, timer callbacks
- Leads to deadlock if script have a handler for the dispatched message
- Script unload will wait until context is unblocked
- name()
Return: String name of the message
- broadcast()
Return: Boolean broadcast flag
- getParam(name)
- getParam(name,defValue)
- getParam(name,defValue,autoNumber)
Parameters:
name - Name of the parameter to retrieve
defValue - Value to return if parameter is missing, default undefined
autoNumber - Automatically convert parameters to boolean or number type, default true
Return: Value of parameter, even if name matches a method name
- setParam(name,value)
Parameters:
name - Name of the parameter to set
value - New value to set in parameter, undefined to delete the parameter
Return: True on success, false if message was not in a state where parameters can be changed
- clearParam(name[,sep)
Parameters:
name - Name of the parameter to clear
sep - Optional name separator (first character only)
Return: True on success, false if message was not in a state where parameters can be changed, undefined if name is not given
- copyParams(obj,prefix,skip)
Parameters:
obj - object from which to copy properties (except objects, null and undefined)
prefix - optional parameter to specify that only properties that a key with the given index should be copied. If the prefix represents an object, the properties of that object will be copied.
skip - optional parameter (assumed, by default, to be true) to specifies if the prefix should be copied or eliminated from the key being copied.
- retValue()
Return: Returned value of the message
- retValue(value)
Parameters:
value - New returned value to set in the message
- msgTime()
Return: Message creation time in milliseconds since EPOCH, null if message is not valid
- msgTime(value)
Parameters:
value - Message creation time in milliseconds since EPOCH. Boolean true to set current time
Return: True if message creation time changed, false otherwise
- msgAge()
Return: Message age in milliseconds
- getColumn([indexOrName])
Retrieve one or all columns from message user data table.
Message user data is set after a database query. Database query result contains field names and query result data (values).
Parameters:
indexOrName - Optional column numeric index or name
Return:
null if given column index or name is not found or result set is empty
Column given: array with column values
Otherwise: Object with all result set data. Object property names are set to field names. Object property values are array with column values.
- getRow([index])
Retrieve one or all rows from message user data table.
Message user data is set after a database query. Database query result contains field names and query result data (values).
Parameters:
index - Optional row numeric index
Return:
null if given row index is not found or result set is empty
Row given: Object. Object property names are set to field names. Object property values are field values.
Otherwise: Array of objects. Each object is a row.
- getResult(rowIndex,columnIndexOrName)
Retrieve a value from message user data table.
Message user data is set after a database query. Database query result contains field names and query result data (values).
Parameters:
rowIndex - Row numeric index
columnIndexOrName - Column numeric index or name
Return:
Found value or null if cell given by row/column is not found or result set is empty