[erlang-questions] Asterisk manager parser question
Jon Gretar Borgthorsson
Thu Jun 26 12:05:46 CEST 2008
I've been playing around with erlang for a month and playing around with
gen_tcp and more. Now I've decided to redo a script that I have that parses
events from the asterisk management api. The old script tended to be a bit
unstable and I think that Erlang would be perfect for the job.
However I'm having a little problem solving how to read the information in
an elegant way.
Basically for those who don't know the Asterisk manager API then it's
basically a tcp port you connect to and read events as they come. Each event
is formatted like this:
And events are seperated by 2 returns. What I was thinking of doing is
something that listens to the port and sends events clause in whole to
another process that analyzes it. What I'm having problems with is just the
first part. Recognizing the event clouses in some elegant way and sending
them on to the parsing function. I have to try to save the message up in a
buffer and when it senses 2 returns then creates a process to parse it and
clears the buffer to read the next event. I'm sure that there is some
elegant way to do this but since this is my first real erlang project then
I'm a bit lost on how the best way is. Almost everything else I have figured
out and it's just this last problem that needs solving.
Anyone have a few free minutes to assist me on this?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the erlang-questions