Skip to content

Conversation

BrennanConroy
Copy link
Member

Pre-req for MessagePack support

virtual std::string write_message(const signalr::value&) const = 0;
virtual std::vector<signalr::value> parse_messages(const std::string&) const = 0;
virtual std::string write_message(const hub_message_base*) const = 0;
virtual std::vector<std::unique_ptr<hub_message_base>> parse_messages(const std::string&) const = 0;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a fan of this, but it's the only (clean) way I could think of passing the message type back to the connection.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't think of anything better at the moment, but can we rename hub_message_base to hub_message?

@@ -20,12 +20,13 @@ namespace signalr
public:
explicit default_websocket_client(const signalr_client_config& signalr_client_config = {}) noexcept;

void start(const std::string& url, transfer_format format, std::function<void(std::exception_ptr)> callback);
void start(const std::string& url, signalr::transfer_format format, std::function<void(std::exception_ptr)> callback);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A WebSocket can switch between text an binary in the same connection, right? Could we make the transfer_format an argument to send and receive rather than start? I know SignalR doesn't need to ever switch mid-connection, but it seems like a cleaner to match what the protocol allows.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know the other clients do it this way. I never liked that about the other clients either. Let's make this one a bit more flexible.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated, with this change the transport has to figure out the format itself in the receive loop. At least for WebSockets this is fine

@BrennanConroy BrennanConroy merged commit 9927ad4 into main Mar 16, 2021
@BrennanConroy BrennanConroy deleted the brecon/protocol branch March 16, 2021 22:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants