Refactor websocket events