ws server code