** Sent on a `WebSocket` message event.@Jsclass MsgEvent {** Set in a text message. Str? txt** Set in a binary message. Buf? bufinternalnew make(|This|in){ in(this)} @NoDocoverride Str toStr(){ txt == null ? "Binary - $buf" : "Text - $txt"}}** Sent on a `WebSocket` close event.@Jsconstclass CloseEvent {** Returns 'true' if the connection was closed cleanly.const Bool wasClean** The WebSocket connection close code provided by the server.** Returns 'null' if the connection was not closed cleanly.const Int? code** The WebSocket connection close reason provided by the server.** Returns 'null' if the connection was not closed cleanly.const Str? reasoninternalnew make(|This|in){ in(this)}internal Void writeFrame(WebSocket webSocket){ webSock := (WebSocketFan) webSocket webSock.readyState = ReadyState.closing// this writeFrame() method is always called within the context of "WebSocketFan" - so no JS frame := Frame.makeCloseFrame(code, reason)try webSock.writeFrame(frame)catch{/* meh */}} @NoDocoverride Str toStr(){ str := (wasClean ? "Clean" : "Unclean") + " close"if(code != null){ str += " - ${code}"if(reason.trimToNull != null && reason.trim != "null") str += ": ${reason}"}elseif(reason.trimToNull != null && reason.trim != "null") str += " - ${reason}"return str}}