Components | All | New | MacOS | Windows | Linux | iOS | ||||
Examples | Mac & Win | Server | Client | Guides | Statistic | FMM | Blog | Deprecated | Old |
WebHook.SetMode
Sets mode flags.
Component | Version | macOS | Windows | Linux | Server | iOS SDK |
WebHook | 11.5 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |
Parameters
Parameter | Description | Example |
---|---|---|
WebHook | The reference number of the web hook. | $webhook |
Mode | The new mode. | 1+2 |
Result
Returns OK or error.
Description
Sets mode flags.Pass 1 for keeping connection open.
Pass 2 for accepting non HTTP connections, e.g. to accept notifications from devices like scales.
If connection stays open, you can send a custom answer in the triggered script via WebRequest.Send function. Pass also empty text for WebHook.SetAutoAnswer to disable auto answering.
The RAW connection option allows you to accept other data than HTTP requests. Use WebRequest.GetRawData to read the data coming in. Use either WebHook.SetAutoAnswer to automatically send data or use flag 1 to also keep connection open to use WebRequest.Send function to send your answer.
Examples
Create web hook with keep connection:
If [ IsEmpty ( $$WebHooks ) ]
Set Variable [ $$WebHooks ; Value: MBS("WebHook.Create") ]
#
# enable keep open and disable auto answer, so we can send custom answer
Set Variable [ $r ; Value: MBS("WebHook.SetAutoAnswer"; $$Webhooks; ""; "UTF-8") ]
Set Variable [ $r ; Value: MBS("WebHook.SetMode"; $$WebHooks; 1) ]
#
Set Variable [ $r ; Value: MBS("WebHook.Listen"; $$WebHooks; WebHook::Server Port) ]
Set Variable [ $r ; Value: MBS("WebHook.SetScript"; $$WebHooks; Get(FileName); "WebHookReceived With KeepOpen") ]
Set Field [ WebHook::Server Webhook ; $$WebHooks ]
End If
Start a RAW hook:
If [ IsEmpty ( $$WebHooks ) ]
Set Variable [ $$WebHooks ; Value: MBS("WebHook.Create") ]
#
# enable keep open and disable auto answer, so we can send custom answer
Set Variable [ $r ; Value: MBS("WebHook.SetAutoAnswer"; $$Webhooks; ""; "UTF-8") ]
Set Variable [ $r ; Value: MBS("WebHook.SetMode"; $$WebHooks; 2+1) ]
#
Set Variable [ $r ; Value: MBS("WebHook.Listen"; $$WebHooks; WebHook::Server Port) ]
Set Variable [ $r ; Value: MBS("WebHook.SetScript"; $$WebHooks; Get(FileName); "WebHookReceived With RAW Mode") ]
Set Field [ WebHook::Server Webhook ; $$WebHooks ]
End If
See also
- WebHook.Create
- WebHook.GetMode
- WebHook.GetPort
- WebHook.List
- WebHook.Listen
- WebHook.SetScript
- WebHook.SetSSL
- WebHook.SetTag
- WebRequest.GetRawData
- WebRequest.Send
Example Databases
Blog Entries
This function checks for a license.
Created 17th October 2021, last changed 18th October 2021