[Asterisk-Dev] Realtime agents.

José Pablo Ezequiel Fernández pablo.fernandez at reliable.com.ar
Fri Sep 2 13:26:31 MST 2005


On Thursday 01 September 2005 19:05, Kevin P. Fleming wrote:
> José Pablo Ezequiel Fernández wrote:
> > To be able to use realtime agents I would need to change that linked list
> > for a method similar to SIP's, right ?
>
> No, you can store the agents in any type of list. See app_queue's
> realtime support for a simpler example.
Oh, ok.
Well, I am analyzing how to do it as cleanly as possible and I sketched a 
possible solution, but I'd like to get feedback from anyone that knows this 
source code.
The function __login_exec is where I started, it gets the agent just by 
iterating over the available agents (and it does it twice, other functions 
are replicating this as well). So, I am creating a function get_agent(const 
char *name) with the purpose of getting an agent based on name.
This function is a copy and paste of the code for getting an agent that you ca 
currently find on __login_exec plus tho code to get a realtime agent... and 
so it begins[1]...
It is all very simple in the first case, I get the agent from the db, if I 
can't find it, the agent doesn't exist. If I get, I build a agent_pvt out of 
it and add it to dagents (a linked list for dynamic agents, the dynamic 
counterpart of agents). And in this case, I just return the recently built 
agent, but latter I will also need: to check if the agent is already in 
dagents, if it is, update its record from the db (the password, the name), if 
it isn't, add it.
But I also have to clean up, that is, remave the dagents that are no longer in 
the db (to avoid using all the memory). And that is new (there's no case 
where an agent is removed).
My questions here are:
- How do I compare db agents to memory agents ? by username ?
- How do I delete an agent ? Just by locking it would be enough ? Or I will 
eventually cause a crash ?
I have made a flow chart of the whole situation marking in red the questions I 
mentioned, any comments are welcome.
Thanks.
-- 
José Pablo Ezequiel Fernández

[1] Kosh, Babylon 5.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Agents.pdf
Type: application/pdf
Size: 22877 bytes
Desc: not available
Url : http://lists.digium.com/pipermail/asterisk-dev/attachments/20050902/fdb57af7/Agents.pdf


More information about the asterisk-dev mailing list