Skip to content Skip to sidebar Skip to footer

Javascript Html5 Canvas Display From Python Websocket Server

I created a websocket server that uses ZeroMQ4 to talk to a middleware. I also created a peice of Javascript to display information back from the middleware. I know the Websocket s

Solution 1:

I managed to solve this problem.

Turns out that my javascript and my python server were wrong.

this is the function that works for me when processing the message from the server:

functiononMessage(evt) {
        var img = newImage();
        img.src = "data:image/png;base64,"+evt.data;
        img.onload = function () {
            context.drawImage(img,0,0);
        }
}

I had to add a base64.b64encode on my server right before I send the picture.

Post a Comment for "Javascript Html5 Canvas Display From Python Websocket Server"