Skip to content

Add Connections method in websocket#284

Merged
lorenzodonini merged 1 commit intolorenzodonini:masterfrom
shiv3:add-connections-method
Jan 19, 2025
Merged

Add Connections method in websocket#284
lorenzodonini merged 1 commit intolorenzodonini:masterfrom
shiv3:add-connections-method

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
}

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