Giter Site home page Giter Site logo

Comments (6)

marcelog avatar marcelog commented on August 28, 2024 1

mmm the idea behind PAMI is that sending an action and getting the response is a sync process, while getting async events from asterisk is .. well, async.

Perhaps I misunderstood you earlier, and perhaps the true thing going on here is that you should be looking at the response object itself instead of listening for the events.

So if you send an action, just look at the events in the response with getEvents(). If instead you want to receive events from asterisk (not related to an action you sent) then yes, you should be getting them in your listeners.

Makes sense?

from pami.

alesf avatar alesf commented on August 28, 2024 1

Man! I missed that the response of the action actually holds all of the events that happened in between the request and ..Complete event.

Thank you for this information. It seems logical now.

Maybe you can include this synchronous process in the documentation or in examples. To me it looked like actions just triggered the events in asynchronous process.

from pami.

marcelog avatar marcelog commented on August 28, 2024 1

Great! :) Will do!

from pami.

marcelog avatar marcelog commented on August 28, 2024

Hi!

The response is considered "complete" here: https://github.com/marcelog/PAMI/blob/master/src/mg/PAMI/Message/Response/ResponseMessage.php#L98

It might be possible that the asterisk version you are using is not sending a "..Complete" event (signaling the end of the related events) or that the event itself has a different name and does not follow the pattern of the others. These inconsistencies happen and were seen in different asterisk versions.

Could you post the action sent and all the related received events logged in log4php?

Thanks!

from pami.

alesf avatar alesf commented on August 28, 2024

This is the relevant part of the code:

$ami_client = new ClientImpl($options);

$ami_client->registerEventListener(
    function (EventMessage $event) {
        echo "\n\n";
        print_r($event->getRawContent());
    }
);

$ami_client->registerEventListener(
    function (EventMessage $event) use ($ami_client) {
        $ami_client->send(new \PAMI\Message\Action\QueueStatusAction());
    },
    function (EventMessage $event) {
        return $event instanceof JoinEvent || $event instanceof LeaveEvent;
    }
);

$ami_client->open();

while(true) {
    usleep(1000);
    $ami_client->process();
}

$ami_client->close();

logged events in log4php:

2015-06-30T18:24:54+00:00 [DEBUG] Pami.ClientImpl: ------ Received: ------ 
Event: Newchannel
Privilege: call,all
Channel: SIP/voip-test-0000013a
ChannelState: 0
ChannelStateDesc: Down
CallerIDNum: 000111222
CallerIDName: 000111222
AccountCode: 
Exten: 386000444555
Context: from-company
Uniqueid: 1435688694.314

2015-06-30T18:24:54+00:00 [DEBUG] Pami.ClientImpl: ----------------
2015-06-30T18:24:54+00:00 [DEBUG] Pami.ClientImpl: ------ Received: ------ 
Event: Join
Privilege: call,all
Channel: SIP/voip-test-0000013a
CallerIDNum: 000111222
CallerIDName: 000111222
ConnectedLineNum: unknown
ConnectedLineName: unknown
Queue: test-queue
Position: 1
Count: 1
Uniqueid: 1435688694.314


2015-06-30T18:24:54+00:00 [DEBUG] Pami.ClientImpl: ------ Sending: ------ 
action: QueueStatus
actionid: 1435688694.9121

----------
2015-06-30T18:24:54+00:00 [DEBUG] Pami.ClientImpl: ------ Received: ------ 
Response: Success
ActionID: 1435688694.9121
Message: Queue status will follow


2015-06-30T18:24:54+00:00 [DEBUG] Pami.ClientImpl: ----------------
2015-06-30T18:24:54+00:00 [DEBUG] Pami.ClientImpl: ------ Received: ------ 
Event: QueueParams
Queue: test-queue
Max: 0
Strategy: ringall
Calls: 1
Holdtime: 21
TalkTime: 22
Completed: 18
Abandoned: 90
ServiceLevel: 0
ServicelevelPerf: 0.0
Weight: 0
ActionID: 1435688694.9121


2015-06-30T18:24:54+00:00 [DEBUG] Pami.ClientImpl: ----------------
2015-06-30T18:24:54+00:00 [DEBUG] Pami.ClientImpl: ------ Received: ------ 
Event: QueueMember
Queue: test-queue
Name: SIP/2
Location: SIP/2
Membership: static
Penalty: 2
CallsTaken: 0
LastCall: 0
Status: 1
Paused: 0
ActionID: 1435688694.9121


2015-06-30T18:24:54+00:00 [DEBUG] Pami.ClientImpl: ----------------
2015-06-30T18:24:54+00:00 [DEBUG] Pami.ClientImpl: ------ Received: ------ 
Event: QueueMember
Queue: test-queue
Name: SIP/1
Location: SIP/1
Membership: static
Penalty: 1
CallsTaken: 1
LastCall: 1435687891
Status: 6
Paused: 0
ActionID: 1435688694.9121


2015-06-30T18:24:54+00:00 [DEBUG] Pami.ClientImpl: ----------------
2015-06-30T18:24:54+00:00 [DEBUG] Pami.ClientImpl: ------ Received: ------ 
Event: QueueEntry
Queue: test-queue
Position: 1
Channel: SIP/voip-test-0000013a
Uniqueid: 1435688694.314
CallerIDNum: 000111222
CallerIDName: 000111222
ConnectedLineNum: unknown
ConnectedLineName: unknown
Wait: 0
ActionID: 1435688694.9121


2015-06-30T18:24:54+00:00 [DEBUG] Pami.ClientImpl: ----------------
2015-06-30T18:24:54+00:00 [DEBUG] Pami.ClientImpl: ------ Received: ------ 
Event: QueueStatusComplete
ActionID: 1435688694.9121


2015-06-30T18:24:54+00:00 [DEBUG] Pami.ClientImpl: ----------------
2015-06-30T18:24:54+00:00 [DEBUG] Pami.ClientImpl: ----------------
2015-06-30T18:24:54+00:00 [DEBUG] Pami.ClientImpl: ------ Received: ------ 
Event: Newchannel
Privilege: call,all
Channel: SIP/1-0000013b
ChannelState: 0
ChannelStateDesc: Down
CallerIDNum: 
CallerIDName: 
AccountCode: 
Exten: 
Context: internal
Uniqueid: 1435688694.315

same part of script output:

Event: Newchannel
Privilege: call,all
Channel: SIP/voip-test-0000013a
ChannelState: 0
ChannelStateDesc: Down
CallerIDNum: 000111222
CallerIDName: 000111222
AccountCode: 
Exten: 386000444555
Context: from-company
Uniqueid: 1435688694.314

Event: Join
Privilege: call,all
Channel: SIP/voip-test-0000013a
CallerIDNum: 000111222
CallerIDName: 000111222
ConnectedLineNum: unknown
ConnectedLineName: unknown
Queue: test-queue
Position: 1
Count: 1
Uniqueid: 1435688694.314

Event: Newchannel
Privilege: call,all
Channel: SIP/1-0000013b
ChannelState: 0
ChannelStateDesc: Down
CallerIDNum: 
CallerIDName: 
AccountCode: 
Exten: 
Context: internal
Uniqueid: 1435688694.315

As you see QueueStatusComplete is called (show in log) but the response events are not dispatched.

My dirty quick fix was to put this code

if ($response !== false && $response->isComplete() && is_array($response->getEvents())) {
    foreach($response->getEvents() as $e) {
        $this->dispatch($e);
    }
}

after this line
https://github.com/marcelog/PAMI/blob/master/src/mg/PAMI/Client/Impl/ClientImpl.php#L276

from pami.

ax-abdullah avatar ax-abdullah commented on August 28, 2024

The QueueParams event raised by QueueStatus Action does not return the queue name. It only returns the queue number
queue: 700
How can I get the queue name?

from pami.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.