diff --git a/internal/session/manager.go b/internal/session/manager.go index a7fbe346..97c70b2b 100644 --- a/internal/session/manager.go +++ b/internal/session/manager.go @@ -197,7 +197,7 @@ func (manager *SessionManagerCtx) ClearHost() { // broadcasts // --- -func (manager *SessionManagerCtx) Broadcast(v interface{}, exclude interface{}) { +func (manager *SessionManagerCtx) Broadcast(event string, payload interface{}, exclude interface{}) { manager.sessionsMu.Lock() defer manager.sessionsMu.Unlock() @@ -212,13 +212,11 @@ func (manager *SessionManagerCtx) Broadcast(v interface{}, exclude interface{}) } } - if err := session.Send(v); err != nil { - manager.logger.Warn().Err(err).Msgf("broadcasting event has failed") - } + session.Send(event, payload) } } -func (manager *SessionManagerCtx) AdminBroadcast(v interface{}, exclude interface{}) { +func (manager *SessionManagerCtx) AdminBroadcast(event string, payload interface{}, exclude interface{}) { manager.sessionsMu.Lock() defer manager.sessionsMu.Unlock() @@ -233,9 +231,7 @@ func (manager *SessionManagerCtx) AdminBroadcast(v interface{}, exclude interfac } } - if err := session.Send(v); err != nil { - manager.logger.Warn().Err(err).Msgf("broadcasting admin event has failed") - } + session.Send(event, payload) } } diff --git a/internal/session/session.go b/internal/session/session.go index b501fb63..41ac12ff 100644 --- a/internal/session/session.go +++ b/internal/session/session.go @@ -79,12 +79,12 @@ func (session *SessionCtx) GetWebSocketPeer() types.WebSocketPeer { return session.websocketPeer } -func (session *SessionCtx) Send(v interface{}) error { +func (session *SessionCtx) Send(event string, payload interface{}) { if session.websocketPeer == nil { - return nil + return } - return session.websocketPeer.Send(v) + session.websocketPeer.Send(event, payload) } // --- diff --git a/internal/types/session.go b/internal/types/session.go index d243ec51..045daf84 100644 --- a/internal/types/session.go +++ b/internal/types/session.go @@ -27,7 +27,7 @@ type Session interface { SetWebSocketPeer(websocketPeer WebSocketPeer) SetWebSocketConnected(websocketPeer WebSocketPeer, connected bool) GetWebSocketPeer() WebSocketPeer - Send(v interface{}) error + Send(event string, payload interface{}) // webrtc SetWebRTCPeer(webrtcPeer WebRTCPeer) @@ -47,8 +47,8 @@ type SessionManager interface { GetHost() Session ClearHost() - Broadcast(v interface{}, exclude interface{}) - AdminBroadcast(v interface{}, exclude interface{}) + Broadcast(event string, payload interface{}, exclude interface{}) + AdminBroadcast(event string, payload interface{}, exclude interface{}) OnCreated(listener func(session Session)) OnDeleted(listener func(session Session))