call()
call(topicURI[, payload[, advancedOptions]])
Make an RPC call to topicURI.
Parameters:
topicURI. Required. A string that identifies the remote procedure to be called. Must meet a WAMP Spec URI requirements.
payload. RPC data. Optional. Maybe any single value or array or hash-table object or null:
If it is an array - it is sent as is as WAMP positional arguments attribute
If it is a single object (without argsList and argsDict keys) - it is sent as is as WAMP key-value arguments attribute
If it is a single Number/String/Boolean/Null value - it is packed into a one-item array and is sent as WAMP positional arguments attribute. Be aware that the receiver will get it in argsList as a one-item array and not as a single value!
It is possible to pass the array and object-like data simultaneously. In this case, pass a hash-table with the next attributes:
argsList: array payload (may be omitted)
argsDict: object payload (may be omitted)
advancedOptions. Optional parameters hash table. Must include any or all of the options:
disclose_me: bool flag of disclosure of Caller identity (WAMP session ID) to endpoints of a routed call
progress_callback: function for handling intermediate progressive call results
timeout: integer timeout (in ms) for the call to finish
ppt_scheme: string Identifies the Payload Schema for Payload Passthru Mode
ppt_serializer: string Specifies what serializer was used to encode the payload
ppt_cipher: string Specifies the cryptographic algorithm that was used to encrypt the payload
ppt_keyid: string Contains the encryption key id that was used to encrypt the payload
Returns promise:
Resolved with one hash-table parameter with the following attributes:
details: hash-table with some additional details
argsList: an optional array containing the original list of positional result elements as returned by the Callee
argsDict: optional hash-table containing the original dictionary of keyword result elements as returned by the Callee
Rejected with one of the Errors instances
Important note on progressive call results:
For getting progressive call results you need to specify progress_callback in advancedOptions. This callback will be fired on every intermediate result. But the last one result or error will be processed on promise returned from the .call(). That means that final call result will be received by call promise resolve handler.
let result = await ws.call('server.time');
console.log('Server time is ' + result.argsList[0]);
try {
await ws.call('start.migration');
console.log('RPC successfully called');
} catch (e) {
console.log('RPC call failed!', e.error);
}
try {
await ws.call('restore.backup', { backupFile: 'backup.zip' });
console.log('Backup successfully restored');
} catch (e) {
console.log('Restore failed!', e.error, e.details);
}Last updated