moved websocket event handlers outside of public api