You can use the PollServiceManager to do this. It's the same mechanism the viewer uses.
However, if only one instance of the application long-polls, that is one thread so you don't need to worry about resources too much. Melanie On 15/09/2012 11:53, Dahlia Trimble wrote: > I've had excellent luck serving many simultaneous long-poll requests with > the HTTP server that comes with OpenSimulator. Bear in mind though that > each active request may consume a thread so you might need to increase > available threads if you see problems. I'm not certain if the request > threads are managed by the threadpool in OpenSimulator or if they are > direct calls into .NET framework. I did search through the code once and > found many threads that were not treadpool managed but I can't remember if > HTTP threads were or not. > > > On Fri, Sep 14, 2012 at 9:07 PM, Edmund Edgar <[email protected]>wrote: > >> I've got a situation with the money module I'm working on where I'd >> like an external program (running on the client PC in parallel to the >> viewer) to be able to be in almost constant contact with the server >> while the user is logged in. (I want it to be able to find out >> whenever the user wanted to buy something.) >> >> I figure I can do this by having the external program long-poll the >> OpenSim server. (The external program makes a request, the server >> waits such time as it has something to tell the external program, then >> responds. It gives up and responds if there's nothing to say after 30 >> seconds or so, at which point the external program will make a new >> request and start the cycle again.) >> >> At this point if I was serving a web application with Apache I'd start >> worrying that I was hogging a bunch of threads and eating through the >> memory. Is this the kind of thing I should be worrying about with >> OpenSim, or can I merrily go ahead and long-poll without worrying? >> >> The kind of thing I'm thinking of follows: >> >> >> public void FirstRegionLoaded () >> >> MainServer.Instance.AddHTTPHandler ("/checkfortransactions/", >> CheckForTransactions); >> >> } >> >> public Hashtable CheckForTransactions(Hashtable request) { >> >> UUID userUUID = (get a user id using a session ID passed in the >> request or something); >> >> int i; >> // poll for 30 seconds then give up >> for (i=0; i<30; i++) { >> if >> (m_transactionsAwaitingNotification.containsKey("userUUID")) { >> // Reply to the request >> Hashtable reply = new Hashtable (); >> reply["int_response_code"] = 200; >> reply["str_response_string"] = "{ Some JSON goes >> here }"; >> reply["content_type"] = "text/json"; >> return reply; >> } >> Thread.Sleep (1000); >> } >> >> Hashtable reply = new Hashtable (); >> reply["int_response_code"] = 204; // No Content >> return reply; >> >> // The client will get this reply then hit /checkfortransactions/ >> again. >> >> } >> >> PS. Thanks for the replies to my C#-ignorant questions on previous threads. >> >> -- >> Edmund Edgar >> Avatar Classroom >> Your classroom, on the web, in a virtual world. >> >> [email protected] >> +81 090 3912 3380 >> Skype: edmundedgar >> Second Life: Edmund Earp >> Linked In: edmundedgar >> Twitter: @edmundedgar >> http://www.avatarclassroom.com >> _______________________________________________ >> Opensim-dev mailing list >> [email protected] >> https://lists.berlios.de/mailman/listinfo/opensim-dev >> > > > > _______________________________________________ > Opensim-dev mailing list > [email protected] > https://lists.berlios.de/mailman/listinfo/opensim-dev _______________________________________________ Opensim-dev mailing list [email protected] https://lists.berlios.de/mailman/listinfo/opensim-dev
