[Freeswitch-users] Generate uniqueid like asterisk

Ryan Harris ryharris at airmail.cc
Mon Nov 19 23:19:04 UTC 2018


On 11/16/18 3:29 AM, Mickael Hubert wrote:
> Hi all,
> currently, I use asterisk uniqueid to lot of internals processes Ex:
> 001-1542296620.1319230
> I want to change asterisk by FS, but I have to keep this uniqueid format.
> I know the format of the uniqueid : [server id]-[timestamp].[random
> integer]
>
> How can I generate it from FS please ?

Touch and edit /usr/share/freeswitch/scripts/uniqueid.lua

Write this to the file:

local server_id = argv[1] or '001' -- defaults system id to '001' if you
don't pass an arg
stream:write(server_id .. '-' .. os.time() .. '.' ..
math.random(1000000,9999999))

Then use this in your XML dialplan:

<action application="set" data="server_id=003"/>

<action application="set" data="UNIQUEID=${lua(uniqueid.lua
${server_id})}"/>

Now you have a UNIQUEID channel variable in the format you requested.




More information about the FreeSWITCH-users mailing list