I won’t be of very much help on the compilation errors but the websocket module is more or less a straight translation from the WebSocket API: https://developer.mozilla.org/en-US/docs/Web/API/WebSocket
As the original author of this module I’m really sorry about the lack of documentation.