export class BrowserWebSocketTransport{constructor(e){this._ws=e,this._ws.addEventListener("message",(e=>{this.onmessage&&this.onmessage.call(null,e.data)})),this._ws.addEventListener("close",(()=>{this.onclose&&this.onclose.call(null)})),this._ws.addEventListener("error",(()=>{})),this.onmessage=null,this.onclose=null}static create(e){return new Promise(((s,t)=>{const n=new WebSocket(e);n.addEventListener("open",(()=>s(new BrowserWebSocketTransport(n)))),n.addEventListener("error",t)}))}send(e){this._ws.send(e)}close(){this._ws.close()}}