提交 a7560c74 authored 作者: Chad Phillips's avatar Chad Phillips

allow customizing Event-Subclass header and prefix for all other headers.

上级 fed7ec8a
......@@ -4,14 +4,16 @@ module(..., package.seeall)
Fires a custom event.
]]
function fire_event(action)
local subclass = action.subclass or "jester"
local event_type = action.event_type
local headers = action.headers
local header_prefix = action.header_prefix or "Jester-"
local body = action.body
if event_type then
local event = freeswitch.Event("custom", "jester::" .. event_type)
local event = freeswitch.Event("custom", subclass .. "::" .. event_type)
if headers then
for k, v in pairs(headers) do
event:addHeader("Jester-" .. k, v)
event:addHeader(header_prefix .. k, v)
end
end
if body then
......
......@@ -6,12 +6,14 @@ jester.help_map.event.actions = {}
jester.help_map.event.actions.fire_event = {}
jester.help_map.event.actions.fire_event.description_short = [[Fires a custom event.]]
jester.help_map.event.actions.fire_event.description_long = [[Fires a custom event. The event name will be 'CUSTOM', and the event type will be 'jester::[event_type]'.
jester.help_map.event.actions.fire_event.description_long = [[Fires a custom event. Event-Name will be 'CUSTOM', and Event-Subclass will be '[subclass]::[event_type]'.
All headers will be prefixed with 'Jester-', and the body will automatically have two newline characters appended to it.]]
The body will automatically have two newline characters appended to it.]]
jester.help_map.event.actions.fire_event.params = {
event_type = [[The event type.]],
subclass = [[(Optional) The first portion of the Event-Subclass header (before the double colons). Default is 'jester'.]],
event_type = [[The second portion of the Event-Subclass header (after the double colons).]],
headers = [[(Optional) A table of event headers, key = header name, value = header description. Note that some headers will need to use the full table key syntax, eg. 'headers = {["Custom-Value"] = "foo"}'.]],
header_prefix = [[(Optional) Prefix all header keys with this string. Defaults to 'Jester-'.]],
body = [[(Optional) The event body.]],
}
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论