Hi..<div><br></div><div>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.</div>
<div><br></div><div>However I'm having a little problem solving how to read the information in an elegant way.</div><div><br></div><div>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:</div>
<div><br></div><blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;">Event: Agentlogoff <br>Agent: <agent> <br>Logintime: <logintime> <br>Uniqueid: <uniqueid> </blockquote>
<div><div><br></div><div>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.</div>
<div><br></div><div>Anyone have a few free minutes to assist me on this?</div><div><br></div><div><br></div><div>Regards</div><div>- Jon</div></div>