httpwebsocket

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2018 License: MIT Imports: 18 Imported by: 0

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