rewrite socket handlers
abstract websocket construction