chan-sccp / PAMI

Fork of PHP Asterisk Manager Interface ( AMI ) supports synchronous command ( action )/ responses and asynchronous events using the pattern observer-listener. Supports commands with responses with multiple events. Very suitable for development of operator consoles and / or asterisk / channels / peers monitoring through SOA, etc
http://marcelog.github.com/PAMI
Apache License 2.0
26 stars 21 forks source link

Async support #14

Closed AlexHighTower closed 2 years ago

AlexHighTower commented 3 years ago

Hello,

Thanks for great job!

Is any plans to make version with async calls support? Now blocking socket read/write functions are used and it is not possible to use in project with AMP for example..

It would be nice to have flag to use AMP and two independent ClientImpl.php implementations...

dkgroot commented 3 years ago

Hi Alex, I did not have any plans in that direction, i would certainly welcome some help in this direction. Two completely separate impl versions might not even be required we could split the current impl file and move the common parts into it's own file. Most of the parsing logic should still be applicable.

The socket read/write implementation has been a bit messy from the start so it may be a bit of a challenge. Would you be interested in helping us out with an initial implementation ?

AlexHighTower commented 3 years ago

Hi,

I have no big experience with AMPHP, just start to use some library in my pet project which uses it... So, I've made quick adaptation of ClientImpl.php to use amphp and I can say it works for me... It is still more or less the same messy implementation... And I faced misunderstanding regarding timeouts... I believe that for AMPHP they should be in milliseconds... may me code should be corrected at contractor part... Here is my implementation for now.

dkgroot commented 3 years ago

Will have a look at the difference after the weekend, thanks for making this initial attempt. Did you managed to run the tests as well ? I guess not, because they would be missing AMP support (for now).

dkgroot commented 3 years ago

@AlexHighTower Could you perform a couple of steps:

Once we have that, i will try create some test cases and adapt the mock system to handle the amp_async version.