prepare for websocket write