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
27 stars 21 forks source link

Problem with linkedid length #7

Closed varlog11 closed 5 years ago

varlog11 commented 5 years ago

if ($callData["event"] == 'CEL') echo $callData["linkedid"].PHP_EOL;

Hello!

I have a problem with CEL events and linkedid. Example. If linkedid = 1573204600.9999 then $ callData ["linkedid"] returns 1573204600.9999 If linkedid = 1573204600.10000 then $ callData ["linkedid"] gives 1573204600.1000

dkgroot commented 5 years ago

@varlog11 Can you give me a little more explanation. Maybe:

varlog11 commented 5 years ago

Sample code in the attached file example.txt

If I use chan-sccp/PAMI I get      ["uniqueid"] =>      float (1573546586.1925)      ["linkedid"] =>      float (1573546586.1925) although I should get 1573546586.19256

If I use marcelog/PAMI I get      ["uniqueid"] =>      float (1573546586.19256)      ["linkedid"] =>      float (1573546586.19256) Everything is fine

tested on asterisk versions 13.29 and 16.6.1

output example (LinkedID: 1573554109.19276 and keys linkedid float(1573554109.1928)): object(PAMI\Message\Event\CELEvent)#8 (7) { ["rawContent":protected]=> string(455) "Event: CEL Privilege: call,all EventName: LINKEDID_END AccountCode: CallerIDnum: 74998884455 CallerIDname: 74998884455 CallerIDani: 74998884455 CallerIDrdnis: CallerIDdnid: 78461112233 Exten: h Context: ext-queues Channel: SIP/test-00000004 Application: AppData: EventTime: 2019-11-12 13:21:52 AMAFlags: DOCUMENTATION UniqueID: 1573554109.19276 LinkedID: 1573554109.19276 Userfield: Peer: PeerAccount: Extra: " ["channelVariables":protected]=> array(1) { ["sip/test-00000004"]=> array(0) { } } ["statusVariables":protected]=> array(1) { ["sip/test-00000004"]=> array(0) { } } ["lines":protected]=> array(0) { } ["variables":protected]=> array(0) { } ["keys":protected]=> array(22) { ["event"]=> string(3) "CEL" ["privilege"]=> string(8) "call,all" ["eventname"]=> string(12) "LINKEDID_END" ["accountcode"]=> NULL ["calleridnum"]=> int(74998884455) ["calleridname"]=> int(74998884455) ["calleridani"]=> int(74998884455) ["calleridrdnis"]=> NULL ["calleriddnid"]=> int(78461112233) ["exten"]=> string(1) "h" ["context"]=> string(10) "ext-queues" ["channel"]=> string(35) "SIP/test-00000004" ["application"]=> NULL ["appdata"]=> NULL ["eventtime"]=> string(19) "2019-11-12 13:21:52" ["amaflags"]=> string(13) "DOCUMENTATION" ["uniqueid"]=> float(1573554109.1928) ["linkedid"]=> float(1573554109.1928) ["userfield"]=> NULL ["peer"]=> NULL ["peeraccount"]=> NULL ["extra"]=> NULL } ["createdDate":protected]=> int(1573554112) }

dkgroot commented 5 years ago

@varlog11 Ooh i see. I did not notice the missing last digit in the uniqueid before.

varlog11 commented 5 years ago

and LinkedID: 1573554109.19276 and keys linkedid float(1573554109.1928) different I think the float(1573554109.1928) should be 1573554109.1927, since LinkedID: 1573554109.19276

varlog11 commented 5 years ago

If I use marcelog/PAMI, I get LinkedID and the key linkedid is the same

example: object(PAMI\Message\Event\CELEvent)#7 (6) { ["rawContent":protected]=> string(451) "Event: CEL Privilege: call,all EventName: CHAN_END AccountCode: CallerIDnum: 74998884455 CallerIDname: 74998884455 CallerIDani: 74998884455 CallerIDrdnis: CallerIDdnid: 78461112233 Exten: h Context: ext-queues Channel: SIP/test-00000005 Application: AppData: EventTime: 2019-11-12 13:26:40 AMAFlags: DOCUMENTATION UniqueID: 1573554390.19283 LinkedID: 1573554390.19283 Userfield: Peer: PeerAccount: Extra: " ["channelVariables":protected]=> array(1) { ["sip/test-00000005"]=> array(0) { } } ["lines":protected]=> array(0) { } ["variables":protected]=> array(0) { } ["keys":protected]=> array(22) { ["event"]=> string(3) "CEL" ["privilege"]=> string(8) "call,all" ["eventname"]=> string(8) "CHAN_END" ["accountcode"]=> string(0) "" ["calleridnum"]=> string(11) "74998884455" ["calleridname"]=> string(11) "74998884455" ["calleridani"]=> string(11) "74998884455" ["calleridrdnis"]=> string(0) "" ["calleriddnid"]=> string(11) "78461112233" ["exten"]=> string(1) "h" ["context"]=> string(10) "ext-queues" ["channel"]=> string(35) "SIP/test-00000005" ["application"]=> string(0) "" ["appdata"]=> string(0) "" ["eventtime"]=> string(19) "2019-11-12 13:26:40" ["amaflags"]=> string(13) "DOCUMENTATION" ["uniqueid"]=> string(16) "1573554390.19283" ["linkedid"]=> string(16) "1573554390.19283" ["userfield"]=> string(0) "" ["peer"]=> string(0) "" ["peeraccount"]=> string(0) "" ["extra"]=> string(0) "" } ["createdDate":protected]=> int(1573554400) }

dkgroot commented 5 years ago

The uniqueid and linkedid are being converted from text to float and get rounded up which causes the change. We should not be converting at all in this case. It should just remain text.

dkgroot commented 5 years ago

I pushed a fix to the master branch, which should take care of the issue, can you verify this ?

varlog11 commented 5 years ago

Yes, now everything is fine. Thanks for the help.

object(PAMI\Message\Event\CELEvent)#8 (7) { ["rawContent":protected]=> string(455) "Event: CEL Privilege: call,all EventName: LINKEDID_END AccountCode: CallerIDnum: 74998884455 CallerIDname: 74998884455 CallerIDani: 74998884455 CallerIDrdnis: CallerIDdnid: 78461112233 Exten: h Context: ext-queues Channel: SIP/test-00000006 Application: AppData: EventTime: 2019-11-12 13:49:55 AMAFlags: DOCUMENTATION UniqueID: 1573555785.19290 LinkedID: 1573555785.19290 Userfield: Peer: PeerAccount: Extra: " ["channelVariables":protected]=> array(1) { ["sip/test-00000006"]=> array(0) { } } ["statusVariables":protected]=> array(1) { ["sip/test-00000006"]=> array(0) { } } ["lines":protected]=> array(0) { } ["variables":protected]=> array(0) { } ["keys":protected]=> array(22) { ["event"]=> string(3) "CEL" ["privilege"]=> string(8) "call,all" ["eventname"]=> string(12) "LINKEDID_END" ["accountcode"]=> NULL ["calleridnum"]=> int(74998884455) ["calleridname"]=> int(74998884455) ["calleridani"]=> int(74998884455) ["calleridrdnis"]=> NULL ["calleriddnid"]=> int(78461112233) ["exten"]=> string(1) "h" ["context"]=> string(10) "ext-queues" ["channel"]=> string(35) "SIP/test-00000006" ["application"]=> NULL ["appdata"]=> NULL ["eventtime"]=> string(19) "2019-11-12 13:49:55" ["amaflags"]=> string(13) "DOCUMENTATION" ["uniqueid"]=> string(16) "1573555785.19290" ["linkedid"]=> string(16) "1573555785.19290" ["userfield"]=> NULL ["peer"]=> NULL ["peeraccount"]=> NULL ["extra"]=> NULL } ["createdDate":protected]=> int(1573555796) }

dkgroot commented 5 years ago

Ok Super Thanks for reporting the issue. Sorry it took a little while for me to understand the issue :-) Updating the docs now !