Jump to content

- Functions

- # NumberOfLoggedInUsersInGroup

  Followers 0

  VBScript → Lua

  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:
      '      sGroup      name or number of group
      '
      ' return value:
      '      integer     number of logged in users
      '--------------------------------------------------------------------
      Function NumberOfLoggedInUsersInGroup ( sGroup )

          PBXScript.OutputTrace("-------------> NumberOfLoggedInUsersInGroup ( sGroup = " & sGroup & " )")

          Dim nReturn
          nReturn = 0

          Dim Users
          Set Users = g_PBXConfig.GetUserByAddress(sGroup)

          Dim User
          For Each User In Users

              PBXScript.OutputTrace("Found user " & User.Name & " with current state " & User.State)

              If User.State > 1 Then nReturn = nReturn + 1

          Next

          NumberOfLoggedInUsersInGroup = nReturn

          PBXScript.OutputTrace("nReturn = " & nReturn)
          PBXScript.OutputTrace("<------------- NumberOfLoggedInUsersInGroup")

      End Function

  Please note that the status signalling between all involved users (incl. the one the current call routing runs for) must be configured (just as in SwyxIt!).

  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

  - July 11, 2024
  Share
  Share
  Followers 0
  Previous Page LogCallIntoTextFile
  Next Page SetNewVoicemailFlag

## Important Information

By using this site, you agree to our Terms of Use and have taken note of our Privacy Policy.
We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.