NanoHttpd/nanohttpd — pull request #109 by yankee42 (2014-04-24 21:53:52+00:00)
Title: Web socket class hierarchy

It bugs me that the WebSocket implementation derives from NanoHTTPD:

1. Only one plugin with this behaviour can exist, because I can impossibly load two such "plugins" on the same instance (I'd need multi inheritance for that)
2. If a non WebSocket requests comes a long super.serve() is called. This may be undesired behaviour, but there is not that much I can do about it
3. Due to the coupling of WebSocket-Impl and NanoHTTPD code becomes more difficult to understand (e.g. unit tests).
4. It is not necessary to couple WebSocket and NanoHTTPD this close together.

This pull request refactors the code to solve these problems. The code was changed carefully to preserve the existing API, however due to missing tests this is obviously hard to guarantee. Due to the refactorings I'd consider to mark certain methods as deprecated or remove them alltogether. I'd be happy to create a follow-up pull request if this request here gets accepted and the clean-up is desired.

Additionally the pull request contain the first couple of unit tests for the module. I believe that my changes will make unit testing in the future easier as well.