Skip to content

Add Connections method in websocket #284

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 19, 2025

Conversation

shiv3
Copy link
Contributor

@shiv3 shiv3 commented Jul 21, 2024

What

Add a method to get websocket connection information

Why

Some of the chargers we are dealing with do not support websocket ping/pong frames and the Disconnected hook may not be called when the connection is lost. So we need the connection information to reconcile the status of the connected chargers.

@lorenzodonini
Copy link
Owner

lorenzodonini commented Jan 19, 2025

Thanks for the contribution. Just fyi, I'll be refactoring the websocket package a bit, meaning you might see different struct naming next time you look at this (I'll try not to break existing implementations). I'll definitely keep your addition though 👍

@lorenzodonini lorenzodonini merged commit 09f559b into lorenzodonini:master Jan 19, 2025
1 of 2 checks passed
@@ -371,6 +375,10 @@ func (server *Server) Addr() *net.TCPAddr {
return server.addr
}

func (server *Server) Connections(websocketId string) *WebSocket {
return server.connections[websocketId]
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this be thread-safe? Could happen you have a connection what is being removed at the same time and you get a stale connection map

Copy link
Owner

Choose a reason for hiding this comment

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

Good point, fixed here

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.

3 participants