ettoreleandrotognoli / python-ami

Python AMI Client
BSD 3-Clause "New" or "Revised" License
107 stars 66 forks source link

Skip empty lines in the Asterisk response #1

Closed psaavedra closed 8 years ago

psaavedra commented 8 years ago

Some Asterisk response and events includes empty lines in the response. For example:

>>> Response: Success
ActionID: 0
Message: Authentication accepted

Event: FullyBooted
Privilege: system,all
Status: Fully Booted

These empty line should be ignored.

ettoreleandrotognoli commented 8 years ago

Before all, thank you for your help!

These empty lines in your example are only at the end of message.

Response: Success ActionID: 0 Message: Authentication accepted << empty line -- end of response >> Event: FullyBooted Privilege: system,all Status: Fully Booted << empty line -- end of event >>

Or are you speaking about other empty lines?

Thanks!

psaavedra commented 8 years ago

yeah, you are right, the problem was in the listen() function. Sometimes the data readed in ''self.socket.recv(self.buffer_size)'' read more tahn one message at the same time. For example:

data: >>>>>>>>>>>>>> Response: Success ActionID: 0 Message: Authentication accepted

Event: FullyBooted Privilege: system,all Status: Fully Booted

data: <<<<<<<<<<<<<<

psaavedra commented 8 years ago

New Pull request submitted: https://github.com/ettoreleandrotognoli/python-ami/pull/2