I'd like to give this a go and was wondering on peoples opinion on which might be the best to approach take to do this.
Considering that it should still be able to serve and work as the current HTTPServer, I was thinking of doing:
1 - a new type of server based on the current HTTPServer (et al.) sources. This will, most probably, produce duplicated code OR
2 - refactoring the current HTTPServer code to add this a capability of it. Integration and refactoring introducing bugs on what is now clean code OR
3 - Code a specialization of HTTPServerRequest (and HTTPServerRequestFactory of course) that can be used to register a particular URL within the current HTTPServer implementation. It most probably need to take over the management of memory and resources associated with the HTTPSession. Im not sure how much knowledge of the inner workings of HTTPServer it would need. This would then could make the code a potential for bugs if HTTPServer code ever changes in the future (high cohesion).
Consider also that there are socket and thread lifetimes to consider.
On thread lifetime, I'm thinking single thread listening to ALL the current active WebSockets (limit?) making use of a threadpool to then pass processing of incoming messages as opposed to a thread per WebSocket connection model.
On socket lifetime, this has to detach the socket from the HTTPServer somehow and take over the management of it and any associated memory and resources HTTPServer has setup (see point 3 above for potential of creating code with a high cohesion factor).
By "give it a go" i obviously mean make the sources available to anyone
http://tools.ietf.org/html/draft-hixie- ... rotocol-75