move websocket callback definition