Smartpoint Cloud Connector Intercepting Commands
This topic explains how to:
-
Register a command to be intercepted
-
What happens when a cryptic command is intercepted
-
How to unregister a command
-
How to unregister all commands
Registering commands to be intercepted
To register commands a message has to be sent using the operation addInterceptCommands. It will expect a list of strings. If those strings start and end with / they will be interpreted as regular expressions. The timeout parameter is optional with a default value of 500. Increasing this value may lead to worse performance.
{
id: GUID | string,
type: "action",
operation: "addInterceptCommands",
parameters: {
regexList: Array<string>,
timeout: Number
}
}
Which will return a response with the same id:
{
id: GUID | string,
type: "action",
operation: "addInterceptCommands",
success: boolean,
result: Object | string
}
Example
Initial request:
{
"id": "123456789",
"type": "action",
"operation": "addInterceptCommands",
"parameters": {
{
"regexList": [ "/^A/", "HELP" ],
"timeout": 500
}
}
}
Expected response:
{
"id": "123456789",
"type": "action",
"operation": "addInterceptCommands",
"result": true,
"success": true
}
If anything goes wrong you will receive a negative success and an explanation on the result.
{
"id": "123456789",
"type": "action",
"operation": "addInterceptCommands",
"result": "Something went wrong",
"success": false
}
A cryptic is intercepted
When a cryptic is intercepted, a message will be sent to the third party application that registered it:
{
id: GUID | string,
type: "event",
operation: "addInterceptCommand",
payload: {
cryptic: string
}
}
This will wait for the third party application to respond with a message or the timeout happens. This message needs to have the same id as the previous one. If the value of intercept is true, the cryptic will be successfully intercepted. If the value of intercept is false or the timeout ends then the cryptic will run as normal on Smartpoint Cloud.
{
id: GUID | string,
type: "callback"
operation: "addInterceptCommand",
result:
{
intercept: boolean
}
}
Example
Initial message:
{
"id": "123456789",
"type": "event",
"operation": "addInterceptCommand",
"payload": {
"cryptic": "ABC"
}
}
Expected response
{
"id": "123456789",
"type": "callback"
"operation": "addInterceptCommand",
"result":
{
"intercept": true
}
}
Unregistering commands
To unregister commands a message has to be sent using the operation cancelInterceptCommands. It will expect a list of cryptic commands or regular expressions.
{
id: GUID | string,
type: "action",
operation: "cancelInterceptCommands",
parameters: {
regexList: Array<string>,
}
}
Which will return a response with the same id:
{
id: GUID | string,
type: "action",
operation: "cancelInterceptCommands",
success: boolean,
result: Object | string
}
Unregistering all the commands
To unregister all the commands a message has to be sent using the operation cancelAllInterceptCommands.
{
id: GUID | string,
type: "action",
operation: "cancelAllInterceptCommands"
}
Which will return a response with the same id:
{
id: GUID | string,
type: "action",
operation: "cancelAllInterceptCommands",
success: boolean,
result: Object | string
}