MCPcopy
hub / github.com/olahol/melody / BroadcastMultiple

Method BroadcastMultiple

melody.go:217–224  ·  view source on GitHub ↗

BroadcastMultiple broadcasts a text message to multiple sessions given in the sessions slice.

(msg []byte, sessions []*Session)

Source from the content-addressed store, hash-verified

215
216// BroadcastMultiple broadcasts a text message to multiple sessions given in the sessions slice.
217func (m *Melody) BroadcastMultiple(msg []byte, sessions []*Session) error {
218 for _, sess := range sessions {
219 if writeErr := sess.Write(msg); writeErr != nil {
220 return writeErr
221 }
222 }
223 return nil
224}
225
226// BroadcastBinary broadcasts a binary message to all sessions.
227func (m *Melody) BroadcastBinary(msg []byte) error {

Callers 2

TestBroadcastFunction · 0.80
TestErrSessionClosedFunction · 0.80

Calls 1

WriteMethod · 0.80

Tested by 2

TestBroadcastFunction · 0.64
TestErrSessionClosedFunction · 0.64