Tectu / malloy

A cross-platform C++20 library providing embeddable server & client components for HTTP and WebSocket.
BSD 3-Clause "New" or "Revised" License
68 stars 8 forks source link

websocket::send() default callback #41

Closed Tectu closed 3 years ago

Tectu commented 3 years ago

In my opinion there are plenty of cases where one might want to send something through a websocket but not necessarily care about the callback. Currently, this requires the user to specify an empty callback handler.

@0x00002a what do you think about providing a default callback handler (an empty one) so a user might just do this:

conn->send(malloy::buffer("foo"));

instead of:

conn->send(malloy::buffer("foo"), [](auto, auto){});
0x00002a commented 3 years ago

Agreed, that would be better. There does need to be a way to report errors though, I don't like the idea of letting the user easily (potentially accidentially even) ignore them, which I guess is more #40.

Tectu commented 3 years ago

I agree. Lets close this down as the future of this will mainly be dictated by the outcome of #40.