Wrapping the connection with a mutex prevents the "concurrent write to websocket connection" panic. The new functions are ReadData() and WriteData so as to not collide with ReadJSON() and WriteJSON().