lorenzodonini / ocpp-go

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

Add support for retrieving listening address of websocket Server #72

Closed michaelbeaumont closed 3 years ago

michaelbeaumont commented 3 years ago

It's still a little cumbersome to use because Start() blocks but this makes it possible to use 0 as the port and let the system pick a port then later see which port was chosen, useful for testing.

lorenzodonini commented 3 years ago

I like the idea of splitting the listen and serve up.

I recently added some "hacky" tests on the errors channel, for increasing coverage. I'll quickly investigate where exactly they are breaking and suggest a solution to the failing test.

lorenzodonini commented 3 years ago

It's still a little cumbersome to use because Start() blocks but this makes it possible to use 0 as the port and let the system pick a port then later see which port was chosen, useful for testing.

You could also modify the Start to accept the full listen address (i.e. :8080). That way, you're not just limited to the port. Just an idea.

michaelbeaumont commented 3 years ago

Yeah, I was going to add that separately but changing the listening IP is useful too. But unrelated to setting port to 0, right?

lorenzodonini commented 3 years ago

Yeah, I was going to add that separately but changing the listening IP is useful too. But unrelated to setting port to 0, right?

Yes, it's unrelated. Feel free to add it in a follow-up MR. It would be a breaking change as well, so no rush.