Coder Social home page Coder Social logo

Comments (5)

gilmaimon avatar gilmaimon commented on July 24, 2024 1

Best of luck! Let me know if you need help with it (my email is in my profile)

from arduinowebsockets.

gilmaimon avatar gilmaimon commented on July 24, 2024

Hi.

What kind of interface are you thinking about? You mean being able to do client.send(jsonObj)?

If you can add some code examples, it might help me understand exactly what you mean 😃

Gil.

from arduinowebsockets.

AlexanderWingard avatar AlexanderWingard commented on July 24, 2024

No, I think I mean being able to do serializeJson(obj, client); and deserializeJson(doc, client); like he is able to do with the regular WiFiClient

Why I started to look into this in the first place was that I caused a stack overflow by using that middle storage char[].

from arduinowebsockets.

gilmaimon avatar gilmaimon commented on July 24, 2024

You don't have to use a middle storage char[], you could use std::string which is returned by msg.rawData() which will not leak and is much safer.

I don't think it is correct to make WebsocketsClient a Stream, because a client is much more than just stream of data. For example, calling serializeJson(obj, client), do you expect the message to be sent as binary message or text? Maybe as the content of a ping?

You could try and extend the library by making WebsocketsClient inherit from the Arduino Stream class, which will give you your desired behavior. Personally, I much prefer the explicit sendJson you implemented.

Gil.

from arduinowebsockets.

AlexanderWingard avatar AlexanderWingard commented on July 24, 2024

Ok, cool! I will use rawData.

Fair, I understand your points on not modifying this library. But maybe I will give it an attempt to do a subclass as you suggest or try as suggested in arduinojson implementing a CustomWriter and a CustomReader. Not very skilled in C++ but I will share my results if I succeed.

Thanks!

from arduinowebsockets.

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.