refactor: drop SendMessage() and merge into SendPermanentBroadCastMessage()

This commit is contained in:
Sebastian Mark 2024-11-21 08:43:02 +01:00
parent df98628d91
commit e8cc2d1808
2 changed files with 2 additions and 7 deletions

View file

@ -24,7 +24,8 @@ func SendPermanentBroadCastMessage() {
mu.Lock()
for _, client := range Clients {
// Send message to client
err := client.SendMessage(websocket.TextMessage, jsonMessage)
client.Conn.SetWriteDeadline(time.Now().Add(SEND_TIMEOUT * time.Second))
err := client.Conn.WriteMessage(websocket.TextMessage, jsonMessage)
if err != nil {
helper.Logger.Info("Error broadcasting to client:", "msg", err, "host", client.RealIP, "clients", len(Clients))
}

View file

@ -21,9 +21,3 @@ type WebsocketClient struct {
LastPong time.Time
RealIP string
}
// Sends a message to the websocket.
func (c *WebsocketClient) SendMessage(messageType int, data []byte) error {
c.Conn.SetWriteDeadline(time.Now().Add(TIMEOUT * time.Second))
return c.Conn.WriteMessage(messageType, data)
}