Add version negotiation to network protocol#98
Conversation
newsch
commented
Aug 29, 2020
|
I'm proud to say this is the first time I've thought "this is a good use-case for GOTO" |
| print_client_addr(cli->addr); | ||
| printf(" referenced by %d\n", cli->uid); | ||
|
|
||
| // protocol negotiation |
There was a problem hiding this comment.
I agree it's not a bad use of GOTO, but I'm not convinced it's a good one either?
You could do the exact same thing with a "negotiate protocol" void function, and at a glance the function signature shouldn't even be too bad (especially if you pass rlen as a parameter).
Also if else statements could work, at the cost of some duplicate code (which I assume is why you got stoked about GOTO in the first place).
I vote for the function, but if you do want to keep the GOTO statement, watch your 6.
There was a problem hiding this comment.
You could do the exact same thing with a "negotiate protocol" void function, and at a glance the function signature shouldn't even be too bad (especially if you pass rlen as a parameter).
Fair. I'm trying to hold off on refactoring any server code to avoid more merge conflicts with #80, which already restructures a fair bit of it.
I'll rewrite this bit as part of #80.
Before making more breaking changes to the networking protocol (like sending user coordinates back and forth for cursor support), it seemed best to add a method of negotiating a protocol version so things can fail or downgrade more gracefully. As implemented here, previous versions of servers and clients will not work with these updated versions. This would be a pretty big problem, except that as far as I know nobody uses this project regularly, especially in a networked/remote capacity. Because previously the client expected canvas data to be sent over immediately, the only way that I can think of to support older clients while not requiring that canvas send is to add a timeout on the server that waits for a version number and then sends the canvas if nothing is sent, which seems pretty unideal.
Bonus: if you squint really hard it looks like ASCII
03cb87f to
1e4c0df
Compare
Oddly the increased compiler warnings didn't reveal this issue... the iteration on line 308 gave me a warning in my editor.