Exemplo n.º 1
0
// new websocket connection wrapper
func NewWSConnection(wsConn *websocket.Conn) *WSConnection {
	return &WSConnection{
		id:        wsConn.RemoteAddr().String(),
		wsConn:    wsConn,
		writeChan: make(chan WSResponse, WriteChanBufferSize), // buffered. we keep track when its full
		quitChan:  make(chan struct{}),
	}
}
Exemplo n.º 2
0
// new websocket connection wrapper
func NewWSConnection(baseConn *websocket.Conn, funcMap map[string]*RPCFunc, evsw *events.EventSwitch) *WSConnection {
	wsc := &WSConnection{
		id:        baseConn.RemoteAddr().String(),
		baseConn:  baseConn,
		writeChan: make(chan RPCResponse, writeChanCapacity), // error when full.
		funcMap:   funcMap,
		evsw:      evsw,
	}
	wsc.QuitService = *NewQuitService(log, "WSConnection", wsc)
	return wsc
}