How to use the websocket.url function in websocket

To help you get started, we’ve selected a few websocket examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Streamedian / html5_rtsp_player / src / rtsp / connection.js View on Github external
connect() {
        this.rtpproxy = null;
        this.proxy = new WebSocketProxy(RTSP_CONFIG['websocket.url'], {host: this.host, port: this.port, auth:this.auth});
        this.proxy.set_message_handler((ev)=>{
            let item = this.response_queue.shift();
            item.resolve(ev.data);
        });
        this.proxy.set_disconnect_handler(()=>{
            if (this.rtpproxy) {
                this.rtpproxy.set_disconnect_handler(()=>{});
                this.rtpproxy.close();
            }
            this.eventSource.dispatchEvent('disconnected');
            setTimeout(()=>{
                this.ready = this.connect();
            }, 3000);
        });

        return this.proxy.connect("rtsp").then((id)=>{
github Streamedian / html5_rtsp_player / src / rtsp / connection.js View on Github external
return this.proxy.connect("rtsp").then((id)=>{
            if (id==-1) {
                throw new Error("failed to connect");
            }
            this.rtpproxy = new WebSocketProxy(RTSP_CONFIG['websocket.url'], {sock_id: id});
            this.rtpproxy.set_message_handler((ev)=>{
                let channel = new DataView(ev.data).getUint8(1);
                if (this.rtp_channels.has(channel)) {
                    this.rtp_handler({packet: new Uint8Array(ev.data, 4), type: channel});
                }
            });
            this.rtpproxy.set_disconnect_handler(()=>{
                if (this.proxy) {
                    this.proxy.close();
                }
            });
            return this.rtpproxy.connect('rtp').then(()=>{
                this.eventSource.dispatchEvent('connected');
            });
        });
    }