httpwebsocket

package
v0.0.2-d277 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2018 License: MIT Imports: 18 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const SessionTimeOut int64 = 120

Variables

View Source
var (
	PushBlockFlag    = true
	PushRawBlockFlag = true
	PushBlockTxsFlag = true
	PushNewTxsFlag   = true
)

Functions

func SendBlock2WSclient

func SendBlock2WSclient(v interface{})

func SendTransaction2WSclient

func SendTransaction2WSclient(v interface{})

func StartServer

func StartServer()

Types

type Handler

type Handler func(map[string]interface{}) map[string]interface{}

type Session

type Session struct {
	sync.Mutex
	Connection *websocket.Conn
	LastActive int64
	SessionId  string
}

func (*Session) Send

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

func (*Session) SessionTimeoverCheck

func (s *Session) SessionTimeoverCheck() bool

type SessionList

type SessionList struct {
	sync.RWMutex
	OnlineList map[string]*Session //key is SessionId
}

func (*SessionList) CloseSession

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

func (*SessionList) ForEachSession

func (sl *SessionList) ForEachSession(visit func(*Session))

type WebSocketServer

type WebSocketServer struct {
	sync.RWMutex
	*http.Server
	net.Listener
	websocket.Upgrader

	SessionList *SessionList
	ActionMap   map[string]Handler
}

func (*WebSocketServer) IsValidMsg

func (server *WebSocketServer) IsValidMsg(reqMsg map[string]interface{}) bool

func (*WebSocketServer) OnDataHandle

func (server *WebSocketServer) OnDataHandle(currentSession *Session, bysMsg []byte, r *http.Request) bool

func (*WebSocketServer) PushResult

func (server *WebSocketServer) PushResult(action string, v interface{})

func (*WebSocketServer) Start

func (server *WebSocketServer) Start()

func (*WebSocketServer) Stop

func (server *WebSocketServer) Stop()

Jump to

Keyboard shortcuts

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