------ art_4260_7882869.1129139900491 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline I've gotten a ways on this project and now have another hurdle to cross. Right now I have a server that connects to the asterisk manager interface (a simple tcp line based protocol) and stays connected, acting as a kind of proxy for connecting clients instead of making a new connection to asterisk for each request. One thread constantly reads events from asterisk. Each event is stuck into a hash and the hash is pushed onto an array. Using the array like this can change, it just happens to be what I've been using so far. Clients connect to the server via drb with a request which is sent to asterisk. The client then waits until a response is available, or until a timeout is reached. Each client request is tagged with a unique id when it is sent to asterisk, and asterisk returns that unique id in the response. So basically the (abbreviated) code structure is like this, with some_request_method being the method that is called from the drb client. What I'm not sure about is how some_request_method will be able to know when the response is available, or actually what would be the right way to do this. some_request_method should block until a response is available. class Asterisk @events = [] @events.extend(MonitorMixin) @events_pending = @events.new_cond def run reader = Thread.new do loop # reading from socket. Each event goes into a hash which is pushed onto @events. end end end def writesock(hash) ## synchronized write to socket connected to asterisk end def some_request_method(hash) writesock(hash) # Wait for a response, which will be a hash return response end end ------ art_4260_7882869.1129139900491--