Files @ 19c2e6216cf8
Branch filter:

Location: light9/light9/web/light9-vidref-live.js

19c2e6216cf8 1.0 KiB application/javascript Show Annotation Show as Raw Download as Raw
Drew Perttula
support disconnect() on a reconnectingWebSocket to make it stop connecting
Ignore-this: db2fa6ff2ccdeadecf1fc7a1d144535c
import { LitElement, TemplateResult, html, css } from '/node_modules/lit-element/lit-element.js';
import debug from '/lib/debug/debug-build-es6.js';
debug.enable('*');
const log = debug('live');
log('hi it is live')

class Light9VidrefLive extends LitElement {
    
    static get properties() {
        return {
            description: { type: String }
        };
    }

    static get styles() {
        return css`
        :host {
            border: 2px solid #46a79f;
            display: inline-block;
        }
        `;
    }

    firstUpdated() {
        const ws = reconnectingWebSocket('live', (msg) => {
            this.shadowRoot.querySelector('#live').src = 'data:image/jpeg;base64,' + msg.jpeg;
            this.description = msg.description;
        });
        
    }

    disconnectedCallback() {
        log('bye');
        
    }
    
    render() {
        return html`
<div>
<div><img id="live" ></div>
<div>${this.description}</div>
</div>
`;

    }
}
customElements.define('light9-vidref-live', Light9VidrefLive);