websocket

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2023 License: MIT Imports: 17 Imported by: 5

Documentation

Index

Constants

View Source
const (

	// PFBlock indicates push block info (JSON format) message to online
	// list when a block added to chain.
	PFBlock uint32 = 1 << iota

	// PFRawBlock indicates push RAW block message to online list when a
	// block added to chain.
	PFRawBlock

	// PFBlockTxs indicates push block transactions info (JSON format) message
	// to online list when a block added to chain.
	PFBlockTxs

	// PFBlockTxs indicates push new transaction info (JSON format) message to
	// online list when a transaction added to mempool.
	PFNewTx
)

Variables

View Source
var (
	ErrSessionExpired    = errors.New("session expired")
	ErrIllegalDataFormat = errors.New("illegal data format")
	ErrInvalidRequest    = errors.New("invalid request")
	ErrInvalidMethod     = errors.New("invalid method")
)

Functions

func DisableLog

func DisableLog()

DisableLog disables all library log output. Logging output is disabled by default until either UseLogger or SetLogWriter are called.

func UseLogger

func UseLogger(logger elalog.Logger)

UseLogger uses a specified Logger to output package logging info. This should be used in preference to SetLogWriter if the caller is also using elalog.

Types

type Config

type Config struct {
	ServiceCfg        *service.Config
	ServePort         uint16
	Flags             uint32
	HeartbeatInterval time.Duration
	Service           *service.HttpService
}

type Handler

type Handler func(htp.Params) (interface{}, error)

Handler is the registered method to handle a http request.

type Response

type Response struct {
	Action string
	Result interface{}
	Error  int
	Desc   string
}

Response represent the response data structure.

type Server

type Server struct {
	websocket.Upgrader
	// contains filtered or unexported fields
}

func NewServer

func NewServer(orgCfg *Config) *Server

func (*Server) GetSessionList

func (s *Server) GetSessionList() *SessionList

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*Server) Start

func (s *Server) Start() error

func (*Server) Stop

func (s *Server) Stop() error

type Session

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

func (*Session) IsTimeout

func (s *Session) IsTimeout() bool

func (*Session) Send

func (s *Session) Send(data []byte) error

type SessionList

type SessionList struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func (*SessionList) CloseSession

func (sl *SessionList) CloseSession(session *Session)

func (*SessionList) ForEach

func (sl *SessionList) ForEach(closure func(*Session))

func (*SessionList) NewSession

func (sl *SessionList) NewSession(conn *websocket.Conn) *Session

Jump to

Keyboard shortcuts

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