refactor: drop SendMessage()
and merge into SendPermanentBroadCastMessage()
This commit is contained in:
parent
c31b994d58
commit
af5b578cb3
2 changed files with 2 additions and 7 deletions
|
@ -25,7 +25,8 @@ func SendPermanentBroadCastMessage() {
|
||||||
mu.Lock()
|
mu.Lock()
|
||||||
for _, client := range Clients {
|
for _, client := range Clients {
|
||||||
// Send message to client
|
// 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 {
|
if err != nil {
|
||||||
helper.Logger.Error("Error broadcasting to client:", "msg", err, "host", client.RealIP, "clients", len(Clients))
|
helper.Logger.Error("Error broadcasting to client:", "msg", err, "host", client.RealIP, "clients", len(Clients))
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,9 +19,3 @@ type WebsocketClient struct {
|
||||||
LastPong time.Time
|
LastPong time.Time
|
||||||
RealIP string
|
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)
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in a new issue