util websocket functions