func (c *ChatterBox) serverReceiver() {
	defer c.makeDead()
	for {
		var sm messages.Server
		select {
		case v := <-c.readConn():
			switch t := v.(type) {
			case error:
				glog.Errorf("client error receiving from server, client is dead: %s", t)
				return
			case messages.Server:
				sm = t
			default:
				glog.Errorf("readConn is broken")
				return
			}
		}
		switch sm.Type {
		case messages.SMError:
			glog.Infof("server sent an error back: %s", sm.Text.Text)
			c.ServerErrors <- errors.New(sm.Text.Text)
		case messages.SMSendText:
			c.Messages <- sm
		case messages.SMSubAck:
			glog.Infof("server acknowledged subscription to channel")
			c.Subscribed <- sm
			c.UserUpdates <- sm.Users
		case messages.SMUserUpdate:
			c.UserUpdates <- sm.Users
		case messages.SMChannelDrop:
			c.ChannelDrop <- struct{}{}
		default:
			glog.Infof("dropping message of type %v, I don't understand the type", sm.Type)
		}
	}
}
serverReceiver receives messages from the ChatterBox server.
package client
import (
	"errors"
	"fmt"
	"sync"
	"sync/atomic"
	"time"
	"github.com/golang/glog"
	"github.com/gorilla/websocket"
	"github.com/johnsiilver/boutique/example/chatterbox/messages"
)
type ChatterBox struct {
	conn *websocket.Conn
	mu      sync.Mutex
	channel atomic.Value
	kill    chan struct{}
	user     atomic.Value  
	dead     atomic.Value  
	deadOnce sync.Once
	Messages chan messages.Server
	ServerErrors chan error
	UserUpdates chan []string
	ChannelDrop chan struct{}
	Subscribed chan messages.Server
	Done chan struct{}
}
func New(addr string) (*ChatterBox, error) {
	d := websocket.Dialer{
		HandshakeTimeout:  10 * time.Second,
		ReadBufferSize:    1024,
		WriteBufferSize:   1024,
		EnableCompression: true,
	}
	conn, resp, err := d.Dial(fmt.Sprintf("ws://%s/", addr), nil)
	if err != nil {
		if resp != nil {
			return nil, fmt.Errorf("problem connecting to server: %s status: %s", resp.Status, err)
		}
		return nil, fmt.Errorf("problem connecting to server: %s", err)
	}
	c := &ChatterBox{
		conn:         conn,
		kill:         make(chan struct{}),
		ServerErrors: make(chan error, 10),
		Messages:     make(chan messages.Server, 10),
		UserUpdates:  make(chan []string, 10),
		ChannelDrop:  make(chan struct{}, 1),
		Subscribed:   make(chan messages.Server, 1),
		Done:         make(chan struct{}),
	}
	c.dead.Store(false)
	c.channel.Store("")
	go c.serverReceiver()
	return c, nil
}