• Joel Martin's avatar
    Refactor and cleanup websocket.py and deps. · 6a883409
    Joel Martin authored
    Moved websocket.py code into a class WebSocketServer. WebSockets
    server implementations will sub-class and define a handler() method
    which is passed the client socket after. Global variable settings have been
    changed to be parameters for WebSocketServer when created.
    
    Subclass implementations still have to handle queueing and sending but
    the parent class handles everything else (daemonizing, websocket
    handshake, encode/decode, etc). It would be better if the parent class
    could handle queueing and sending. This adds some buffering and
    polling complexity to the parent class but it would be better to do so
    at some point. However, the result is still much cleaner as can be
    seen in wsecho.py.
    
    Refactored wsproxy.py and wstest.py (formerly ws.py) to use the new
    class. Added wsecho.py as a simple echo server.
    
    - rename tests/ws.py to utils/wstest.py and add a symlink from
      tests/wstest.py
    
    - rename tests/ws.html to tests/wstest.html to match utils/wstest.py.
    
    - add utils/wsecho.py
    
    - add tests/wsecho.html which communicates with wsecho.py and simply
      sends periodic messages and shows what is received.
    6a883409
wstest.py 18 Bytes