func (serv *SocketServer) Broadcast(eventName string, data interface{}) {
	serv.hub.broadcast(&BroadcastMsg{eventName, data})
}
Broadcast dispatches an event to all Sockets on the SocketServer.
package ss
import (
	"github.com/gorilla/websocket"
	"github.com/raz-varren/log"
	"io"
	"net/http"
	"os"
	"os/signal"
	"strings"
	"sync"
	"syscall"
)
const (  
	startOfHeaderByte uint8 = 1  
	startOfDataByte         = 2  
	SubProtocol string = "sac-sock"
)
type event struct {
	eventName    string
	eventHandler func(*Socket, []byte)
}
type SocketServer struct {
	hub              *socketHub
	events           map[string]*event
	onConnectFunc    func(*Socket)
	onDisconnectFunc func(*Socket)
	l                *sync.RWMutex
	upgrader         *websocket.Upgrader
}
func NewServer() *SocketServer {
	s := &SocketServer{
		hub:      newHub(),
		events:   make(map[string]*event),
		l:        &sync.RWMutex{},
		upgrader: DefaultUpgrader(),
	}
	return s
}
func (serv *SocketServer) EnableSignalShutdown(complete chan<- bool) {
	c := make(chan os.Signal, 1)
	signal.Notify(c,
		syscall.SIGHUP,
		syscall.SIGINT,
		syscall.SIGTERM,
		syscall.SIGQUIT,
		syscall.SIGKILL)
	go func() {
		<-c
		complete <- serv.Shutdown()
	}()
}
func (serv *SocketServer) Shutdown() bool {
	log.Info.Println("shutting down")
	serv.hub.shutdownCh <- true
	socketList := <-serv.hub.socketList
	for _, s := range socketList {
		s.Close()
	}
	if serv.hub.multihomeEnabled {
		log.Info.Println("shutting down multihome backend")
		serv.hub.multihomeBackend.Shutdown()
		log.Info.Println("backend shutdown")
	}
	log.Info.Println("shutdown")
	return true
}
type EventHandler interface {
	HandleEvent(*Socket, []byte)
	EventName() string
}
func (serv *SocketServer) On(eventName string, handleFunc func(*Socket, []byte)) {
	serv.events[eventName] = &event{eventName, handleFunc}  
}
func (serv *SocketServer) OnEvent(h EventHandler) {
	serv.On(h.EventName(), h.HandleEvent)
}
func (serv *SocketServer) OnConnect(handleFunc func(*Socket)) {
	serv.onConnectFunc = handleFunc
}
func (serv *SocketServer) OnDisconnect(handleFunc func(*Socket)) {
	serv.onDisconnectFunc = handleFunc
}
func (serv *SocketServer) WebHandler() http.Handler {
	return serv
}
func (serv *SocketServer) ServeHTTP(w http.ResponseWriter, r *http.Request) {
	ws, err := serv.upgrader.Upgrade(w, r, nil)
	if err != nil {
		log.Err.Println(err)
		return
	}
	serv.loop(ws)
}
func DefaultUpgrader() *websocket.Upgrader {
	u := &websocket.Upgrader{
		Subprotocols: []string{SubProtocol},
	}
	return u
}
func (serv *SocketServer) SetUpgrader(u *websocket.Upgrader) {
	serv.upgrader = u
}
func (serv *SocketServer) SetMultihomeBackend(b MultihomeBackend) {
	serv.hub.setMultihomeBackend(b)
}
func (serv *SocketServer) Roomcast(roomName, eventName string, data interface{}) {
	serv.hub.roomcast(&RoomMsg{roomName, eventName, data})
}