listenForSocketEvents()

in src/js/client/app.ts [82:106]


    listenForSocketEvents() {
        // only in localhost
        const me = this;
        let url = location.protocol+'//'+location.hostname;
        if(location.hostname === 'localhost' && location.port === '8080'){
        url = location.protocol+'//'+location.hostname+ ':8080';
        }

        me.socket = io(url);
        me.socket.binaryType = 'arraybuffer';

        // socket.io binary
        me.socket.on('broadcast', function(audioBuffer:any) {
            if(audioBuffer) microphone.playOutput(audioBuffer);
        });
        me.socket.on('imgresult', function(text: string) {
            me.pageStatus.innerHTML = text;
        });

        window.addEventListener('cameraPhoto', function(e:CustomEvent) {
            me.socket.emit('snapshot', e.detail);
            me.pageStatus.className = 'view__status';
            me.speak();
        });
    }