Browse Source

add async writes to broadcast

master
Ola Holmström 10 years ago
parent
commit
facd4b1d69
  1. 4
      hub.go
  2. 2
      melody_test.go

4
hub.go

@ -31,10 +31,10 @@ func (h *hub) run() {
for s := range h.sessions { for s := range h.sessions {
if m.filter != nil { if m.filter != nil {
if m.filter(s) { if m.filter(s) {
s.writeMessage(m)
go s.writeMessage(m)
} }
} else { } else {
s.writeMessage(m)
go s.writeMessage(m)
} }
} }
} }

2
melody_test.go

@ -167,7 +167,6 @@ func TestUpgrader(t *testing.T) {
} }
} }
/*
func TestBroadcast(t *testing.T) { func TestBroadcast(t *testing.T) {
broadcast := NewTestServer() broadcast := NewTestServer()
broadcast.m.HandleMessage(func(session *Session, msg []byte) { broadcast.m.HandleMessage(func(session *Session, msg []byte) {
@ -212,7 +211,6 @@ func TestBroadcast(t *testing.T) {
t.Error(err) t.Error(err)
} }
} }
*/
func TestBroadcastOthers(t *testing.T) { func TestBroadcastOthers(t *testing.T) {
broadcast := NewTestServer() broadcast := NewTestServer()

Loading…
Cancel
Save