lorenzodonini / ocpp-go

Open Charge Point Protocol implementation in Go
MIT License
262 stars 125 forks source link

Refactor websocket close logic #102

Closed lorenzodonini closed 3 years ago

lorenzodonini commented 3 years ago
michaelbeaumont commented 3 years ago

There's no reason to have different readPump/writePump methods for client and server is there? Or put another way, I think the right abstraction might be "connection" and "server", where a server just manages multiple connections.

lorenzodonini commented 3 years ago

There's no reason to have different readPump/writePump methods for client and server is there? Or put another way, I think the right abstraction might be "connection" and "server", where a server just manages multiple connections.

There are a few subtle differences between the two, like:

I could definitely abstract this away with a few function parameters, pass a nil channel to the entity that doesn't send the ping and add a couple more conditions, but I'm afraid it won't read as nicely and look as clean. I'm willing to give it a try, if you believe it would be worth it, but in general I'm not against code duplication, when two entities actually behave differently.

lorenzodonini commented 3 years ago

I merged this one for now, will tackle your suggestion in a separate MR.