fixed issue w/ buffer blocking on write to websocket

This commit is contained in:
Brad Rydzewski
2014-07-11 16:52:22 -07:00
parent fa0213ab8d
commit 6375eaa552
7 changed files with 22 additions and 22 deletions

View File

@@ -22,7 +22,9 @@ func (b *Buffer) Write(p []byte) (n int, err error) {
}
func (b *Buffer) WriteString(s string) (n int, err error) {
return b.Write([]byte(s))
n, err = b.buf.WriteString(s)
b.channel.Publish([]byte(s))
return
}
func (b *Buffer) Bytes() []byte {

View File

@@ -29,8 +29,7 @@ func NewChannel(opts *Opts) *Channel {
}
func (c *Channel) Publish(data interface{}) {
c.broadcast <- data
return
go func() { c.broadcast <- data }()
}
func (c *Channel) Subscribe() *Subscription {