Documentation ¶
Index ¶
- func OnConnect(wm *WebsocketManager) func(wsc *wsConnection)
- func OnDisconnect(onDisconnect func(remoteAddr, pubKey string)) func(*wsConnection)
- func PingPeriod(pingPeriod time.Duration) func(*wsConnection)
- func ReadLimit(readLimit int64) func(*wsConnection)
- func ReadWait(readWait time.Duration) func(*wsConnection)
- func WriteChanCapacity(cap int) func(*wsConnection)
- func WriteWait(writeWait time.Duration) func(*wsConnection)
- type IWebsocketManager
- type RequestMsg
- type ResponseMsg
- type WSServer
- type WebsocketManager
- func (wm *WebsocketManager) AliveNodes() []string
- func (wm *WebsocketManager) JudgeWssConnectPermission(activeTssMembers, inActiveTssMembers []string, nodePublicKey string) bool
- func (wm *WebsocketManager) RegisterResChannel(requestId string, recvChan chan ResponseMsg, stopChan chan struct{}) error
- func (wm *WebsocketManager) SendMsg(msg RequestMsg) error
- func (wm *WebsocketManager) SetLogger(l log.Logger)
- func (wm *WebsocketManager) SetWsConnOptions(wsConnOptions ...func(*wsConnection))
- func (wm *WebsocketManager) WebsocketHandler(w http.ResponseWriter, r *http.Request)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func OnConnect ¶
func OnConnect(wm *WebsocketManager) func(wsc *wsConnection)
func OnDisconnect ¶
func OnDisconnect(onDisconnect func(remoteAddr, pubKey string)) func(*wsConnection)
OnDisconnect sets a callback which is used upon disconnect - not Goroutine-safe. Nop by default.
func PingPeriod ¶
PingPeriod sets the duration for sending websocket pings. It should only be used in the constructor - not Goroutine-safe.
func ReadLimit ¶
func ReadLimit(readLimit int64) func(*wsConnection)
ReadLimit sets the maximum size for reading message. It should only be used in the constructor - not Goroutine-safe.
func ReadWait ¶
ReadWait sets the amount of time to wait before a websocket read times out. It should only be used in the constructor - not Goroutine-safe.
func WriteChanCapacity ¶
func WriteChanCapacity(cap int) func(*wsConnection)
WriteChanCapacity sets the capacity of the websocket write channel. It should only be used in the constructor - not Goroutine-safe.
Types ¶
type IWebsocketManager ¶
type IWebsocketManager interface { AliveNodes() []string RegisterResChannel(id string, responseMsg chan ResponseMsg, stopChan chan struct{}) error SendMsg(request RequestMsg) error }
type RequestMsg ¶
type RequestMsg struct { RpcRequest tmtypes.RPCRequest TargetNode string }
type ResponseMsg ¶
type ResponseMsg struct { RpcResponse tmtypes.RPCResponse SourceNode string }
type WebsocketManager ¶
WebsocketManager provides a WS handler for incoming connections and passes a map of functions along with any additional params to new connections. NOTE: The websocket path is defined externally, e.g. in node/node.go
func NewWSServer ¶
func NewWSServer(localAddr string) (*WebsocketManager, error)
func NewWebsocketManager ¶
func NewWebsocketManager( wsConnOptions ...func(*wsConnection), ) *WebsocketManager
NewWebsocketManager returns a new WebsocketManager that passes a map of functions, connection options and logger to new WS connections.
func (*WebsocketManager) AliveNodes ¶
func (wm *WebsocketManager) AliveNodes() []string
func (*WebsocketManager) JudgeWssConnectPermission ¶
func (wm *WebsocketManager) JudgeWssConnectPermission(activeTssMembers, inActiveTssMembers []string, nodePublicKey string) bool
func (*WebsocketManager) RegisterResChannel ¶
func (wm *WebsocketManager) RegisterResChannel(requestId string, recvChan chan ResponseMsg, stopChan chan struct{}) error
func (*WebsocketManager) SendMsg ¶
func (wm *WebsocketManager) SendMsg(msg RequestMsg) error
func (*WebsocketManager) SetLogger ¶
func (wm *WebsocketManager) SetLogger(l log.Logger)
SetLogger sets the logger.
func (*WebsocketManager) SetWsConnOptions ¶
func (wm *WebsocketManager) SetWsConnOptions(wsConnOptions ...func(*wsConnection))
func (*WebsocketManager) WebsocketHandler ¶
func (wm *WebsocketManager) WebsocketHandler(w http.ResponseWriter, r *http.Request)
WebsocketHandler upgrades the request/response (via http.Hijack) and starts the wsConnection.