Skip to content

Binary data #15

Description

@wojciesh

Hi, thanks for a nice lib.

Is sending/receiving binary data not supported, or I just don't know how to use the lib?
When I try to send binary data (image) I get an error "Could not decode a text frame as UTF-8."

My test code is your demo code with this one change in line 14 in demo\server.php:

$socket->sendData($item, file_get_contents('tst.webp'));

and this change in demo\index.html:

websocket.onmessage = function (ev) {
var img = document.createElement('img');
img.src = 'data:image/webp;base64,' + btoa(ev.data);
document.body.appendChild(img);
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions