Lua → VBScript
This function returns the number of currently logged in users (regardless if free or busy) into a given group.
Please see the Introduction chapter for some usage instructions.
------------------------------------------------------------------ -- NumberOfLoggedInUsersInGroup -- -- Returns the number of users which are currently logged in into the given group. -- The users need to have a higher status as "1", i.e. being logged in (regardless if free or busy). -- -- Parameter: -- sNumber uname or number of group -- -- Return: -- integer number of logged in users ------------------------------------------------------------------ function NumberOfLoggedInUsersInGroup( sGroup ) PBXScript.OutputTrace ("-------------> NumberOfLoggedInUsersInGroup ( sGroup = " .. sGroup .. " )") local nReturn = 0 local oUsers = nil oUsers = PBXScript.GetUserByAddress(sGroup) if (oUsers ~= nil) then for i = 1, #oUsers do PBXScript.OutputTrace ("Found user '" .. oUsers[i]:Name() .. "' with current state '" .. oUsers[i]:State() .. "'") if (oUsers[i]:State() > 1) then nReturn = nReturn + 1 end end PBXScript.OutputTrace ("nReturn = " .. tostring(nReturn)) PBXScript.OutputTrace ("<------------- NumberOfLoggedInUsersInGroup") return bReturn end
This function makes use of the Server Script API functions PBXConfig.GetUserByAddress() to resolve all users in the given group to get their status and PBXScript.OutputTrace() to write trace information into the SwyxServer trace file.
This function is also featured in this blog article.
By Tom Wellige
Recommended Comments
There are no comments to display.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now