Skip to content

Implement Arduino Print's methods in WebsocketsClient #94

Open
@arnoson

Description

@arnoson

Is your feature request related to a problem? Please describe.
I want to recievce/send OSC messages over a websocket connection using this OSC library.
But the OSC library is using a more low level way of recieving/sending messages.
Receiving messages works fine with a bit of casting:

WebsocketsMessage msg = client.readBlocking();
OSCMessage oscMsg;
oscMsg.fill(
  reinterpret_cast<uint8_t*>(const_cast<char*>(msg .c_str())),
  msg.length()
);

But sending requires a class that extends Arduino's Print class.

Describe the solution you'd like
Maybe we can implement the relevant Arduino Print's methods in the WebsocketsClient client class?
Than it would be as easy as oscMessage.send(myWebsocketsClient)
The methods would be:

size_t write(const uint8_t *buffer, size_t size)

and

size_t write(uint8_t)

I'm not sure if its enough to just implement these methods or do we really have to extend the Print class?

Describe alternatives you've considered
Maybe I can also create an intermediate class that extends Arduino's Print class. But than the problem would be that I can't access the write methods of the protected underlying Ethernet or Wifi client of a WebsocketsClient.
Another alternative would be to somehow write the OSC message to a WSInterfaceString or a char buffer und send this, though I don't how to do this

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions