Coder Social home page Coder Social logo

Comments (4)

eidheim avatar eidheim commented on May 23, 2024 1

See SocketServerBase::Message::fin_rsv_opcode. For instance inside the onmessage lamda: message->fin_rsv_opcode. If I remember correctly, the codes are the same as when sending to the client: https://github.com/eidheim/Simple-WebSocket-Server/blob/master/server_ws.hpp#L224

from simple-websocket-server.

eidheim avatar eidheim commented on May 23, 2024 1

Yes, fin_rsv_opcode is a way to check if the data is binary or not. https://github.com/eidheim/Simple-WebSocket-Server/blob/master/server_ws.hpp#L117 subclasses std::istream, so you can use std::istream::read (Message::read). You can also use the Message::string() method as it does not matter if its return is binary or text, the only difference is how you would use it. For instance, you would not try to output binary data to a terminal.

from simple-websocket-server.

qingxiang-jia avatar qingxiang-jia commented on May 23, 2024

Thanks.

Do you mean we can use fin_rsv_opcode to test if the message contains binary data? I guess my problem is that I know for sure the message will contain binary data, but I want to get the data. I check the source (https://github.com/eidheim/Simple-WebSocket-Server/blob/master/server_ws.hpp#L117) and found the class Message doesn't seem to provide a way to access the data (string() will just return the data parsed as string, right?). I guess maybe I need to modify class Message a bit to access the data? I am new to C++, so my question may sound stupid :)

from simple-websocket-server.

qingxiang-jia avatar qingxiang-jia commented on May 23, 2024

I see. Thank you so much for the help. I will test it after work.

from simple-websocket-server.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.