websocket

package
v1.8.0-alpha Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 8, 2019 License: LGPL-3.0 Imports: 15 Imported by: 6

Documentation

Overview

Package websocket privides websocket server handler

Index

Constants

View Source
const (
	WSTOPIC_EVENT      = 1
	WSTOPIC_JSON_BLOCK = 2
	WSTOPIC_RAW_BLOCK  = 3
	WSTOPIC_TXHASHS    = 4
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

type WsServer

type WsServer struct {
	sync.RWMutex
	Upgrader websocket.Upgrader

	SessionList  *session.SessionList // websocket sesseionlist
	ActionMap    map[string]Handler   //handler functions
	TxHashMap    map[string]string    //key: txHash   value:sessionid
	SubscribeMap map[string]subscribe //key: sessionId   value:subscribeInfo
	// contains filtered or unexported fields
}

func InitWsServer

func InitWsServer() *WsServer

init websocket server

func (*WsServer) BroadcastToSubscribers

func (self *WsServer) BroadcastToSubscribers(contractAddrs map[string]bool, sub int, resp map[string]interface{})

func (*WsServer) InsertTxHashMap

func (self *WsServer) InsertTxHashMap(txhash string, sessionid string)

func (*WsServer) IsValidMsg

func (self *WsServer) IsValidMsg(reqMsg map[string]interface{}) bool

func (*WsServer) OnDataHandle

func (self *WsServer) OnDataHandle(curSession *session.Session, bysMsg []byte, r *http.Request) bool

func (*WsServer) PushTxResult

func (self *WsServer) PushTxResult(contractAddrs map[string]bool, txHashStr string, resp map[string]interface{})

func (*WsServer) Restart

func (self *WsServer) Restart()

func (*WsServer) Start

func (self *WsServer) Start() error

start websocket server

func (*WsServer) Stop

func (self *WsServer) Stop()

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL