Search code examples
websocketasteriskamazon-ami

How to get via AMI the Pause time of Agent?


I'm making a WebSocket application, and need to get the current Pause Time of an Agent.

When I Call the action: QueueStatus, the return is QueueMember event. an in JSON is returned something like this:

{ActionID: "WelcomeStatus/7000"
CallsTaken: "0"
Event: "QueueMember"
InCall: "0"
LastCall: "0"
LastPause: "1568301325"
Location: "Agent/7000"
Membership: "dynamic"
Name: "Agent/7000"
Paused: "1"
PausedReason: "Almoço"
Penalty: "0"
Queue: "queue1"
StateInterface: "Agent/7000"
Status: "4"}

Note, is returned "LastPause", "PausedReson" and "Pause".. In "LastPause", aways show some crazy number (i dont understand that number hahahahah).

Well, how to get the current pause time from Asterisk 15?

--EDIT: By retesting, I have found that what is causing this is that I am also submitting a Reason for Break. If I do not send the Reason for break time works normally.

Thanks for u help.


Solution

  • Surfing on asterisk's forum, I found the release:

    Bugs fixed in this release: ASTERISK-27541 - app_queue: Queue paused reason was (big number) secs ago when reason is set (Reported by César Benjamín García Martínez)

    But this release is for Asterisk 16, not for Asterisk 15. I've decided to search this issue in some C files, and i found the fail.

    Remember, I have to recompile my asterisk, because I change things straight from the source code. So if you need to perform this procedure, do it in a test environment before it is passed to the production environment.

    Open the file: /usr/src/asterisk-15.7.3/apps/app_queue.c

    And search for this line:

    mem->reason_paused,  (long) (time(NULL) - mem->lastcall), ast_term_reset());
    

    Change:

    mem->reason_paused,  (long) (time(NULL) - mem->lastpause), ast_term_reset());
    

    And on this line:

    "LastPause", (int)mem->lastpause,
    

    Change to:

    "LastPause", (long) (time(NULL) - mem->lastpause),
    

    I think is done... All AMI requests and commands on CLI for me is returning the correct information, and works pretty on my AMI Socket.