Nhowka / Elmish.Bridge

Create client-server Fable-Elmish apps keeping a single mindset
MIT License
139 stars 17 forks source link

DotnetClient stops getting server messages after using AskServer #42

Closed olivercoad closed 2 years ago

olivercoad commented 2 years ago

After solving #40 and going about using AskServer with IReplyChannel, it took me a while to realise that using it seems to break other messages.

Using Bridge.AskServer with a reply channel works fine the first time, but only once, and after using it all other server messages stop being received by the client. The server can still receive messages sent by the client, though.

Also, usually if I stop the server, the client will print debug logs every second with the Bridge.withWhenDown message. But after using a reply channel at least once, if I then stop the server, the client does not even get those connection down messages.

Nhowka commented 2 years ago

Thanks for the report! I'll investigate further what is happening and try to fix it together with the other mistake.

Nhowka commented 2 years ago

It was a bad indentation. The receiver loop was only looping on the normal flow but doing nothing on the branches treating the RPC messages... 🥲

Nhowka commented 2 years ago

Version 6.0.1 should be available soon. Thanks again and sorry about the bad experience.

olivercoad commented 2 years ago

Ah, I see. Good catch. That's a tricky thing with recursive functions that return unit. Making the recursive function have a non-unit return type (perfect use case for something like Bottom Type) can make the compiler help catch these kinds of issues so that you don't accidentally have an implicit base base.

Thanks for looking into it and for the quick fix!

olivercoad commented 2 years ago

*base case.