Instead of using BroadcastFilter just loop over the slice of sessions and broadcast to each one
This commit is contained in:
@@ -234,12 +234,12 @@ func (m *Melody) BroadcastOthers(msg []byte, s *Session) error {
|
|||||||
|
|
||||||
// BroadcastMultiple broadcasts a text message to multiple sessions given in the sessions slice.
|
// BroadcastMultiple broadcasts a text message to multiple sessions given in the sessions slice.
|
||||||
func (m *Melody) BroadcastMultiple(msg []byte, sessions []*Session) error {
|
func (m *Melody) BroadcastMultiple(msg []byte, sessions []*Session) error {
|
||||||
return m.BroadcastFilter(msg, func(q *Session) bool {
|
|
||||||
for _, sess := range sessions {
|
for _, sess := range sessions {
|
||||||
return sess == q
|
if writeErr := sess.Write(msg); writeErr != nil {
|
||||||
|
return writeErr
|
||||||
}
|
}
|
||||||
return false
|
}
|
||||||
})
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// BroadcastBinary broadcasts a binary message to all sessions.
|
// BroadcastBinary broadcasts a binary message to all sessions.
|
||||||
|
|||||||
Reference in New Issue
Block a user