Browse Source
Add convenience function to broadcast to multiple sessions
master
Robbie Trencheny
8 years ago
No known key found for this signature in database
GPG Key ID: 57406F414538A33B
1 changed files with
10 additions and
0 deletions
-
melody.go
|
|
@ -232,6 +232,16 @@ func (m *Melody) BroadcastOthers(msg []byte, s *Session) error { |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
// BroadcastMultiple broadcasts a text message to multiple sessions given in the sessions slice.
|
|
|
|
func (m *Melody) BroadcastMultiple(msg []byte, sessions []*Session) error { |
|
|
|
return m.BroadcastFilter(msg, func(q *Session) bool { |
|
|
|
for _, sess := range sessions { |
|
|
|
return sess == q |
|
|
|
} |
|
|
|
return false |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
// BroadcastBinary broadcasts a binary message to all sessions.
|
|
|
|
func (m *Melody) BroadcastBinary(msg []byte) error { |
|
|
|
if m.hub.closed() { |
|
|
|