examples/video_stream/broadcaster/client/index.js
/**
 * Connects to nodejs server, and perform initial capture after 3 seconds
 * */
Connects to nodejs server, and perform initial capture after 3 seconds
Connects to nodejs server and perform initial capture after 3 seconds
function start() {
    const WS_URL = 'ws://localhost:3001';
    ws = new WebSocket(WS_URL);
    ws.binaryType = "arraybuffer";
    ws.onopen = () => {
        console.log(`Connected to ${WS_URL}`);
        worker.postMessage({
            command : "initialize"
        });
    };
    ws.onmessage = (data) =>{
        let value = data.data;
        let tokens = value.split("|");
        if(tokens[0] == "token")
            document.getElementById('tokenid').innerHTML = "<br><b> Streaming at :</b> " + tokens[1];
        else if(tokens[0] == "message") {
            var node = document.createElement("p");
            var textnode = document.createTextNode(tokens[1]);
            node.appendChild(textnode);
            let chatroom = document.getElementById("chatroom");
            chatroom.appendChild(node);
        }
    }
    setTimeout(()=>{
        Capture();
    }, 3000);
}
function start ( ) { const WS_URL = 'ws://localhost:3001' ; ws = new WebSocket ( WS_URL ) ; ws . binaryType = "arraybuffer" ; ws . onopen = ( ) => { console . log ( ` ${ WS_URL } ` ) ; worker . postMessage ( { command : "initialize" } ) ; } ; ws . onmessage = ( data ) => { let value = data . data ; let tokens = value . split ( "|" ) ; if ( tokens [ 0 ] == "token" ) document . getElementById ( 'tokenid' ) . innerHTML = "<br><b> Streaming at :</b> " + tokens [ 1 ] ; else if ( tokens [ 0 ] == "message" ) { var node = document . createElement ( "p" ) ; var textnode = document . createTextNode ( tokens [ 1 ] ) ; node . appendChild ( textnode ) ; let chatroom = document . getElementById ( "chatroom" ) ; chatroom . appendChild ( node ) ; } } setTimeout ( ( ) => { Capture ( ) ; } , 3000 ) ; }
Connects to nodejs server, and perform initial capture after 3 seconds
Connects to nodejs server and perform initial capture after 3 seconds