webSocket

package
v0.0.0-...-bd0de05 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StartServiceSingleton

func StartServiceSingleton(
	addr string, maxConnNum uint32, connectCallback func(s *session.Session),
)

Types

type CheckAuthCallback

type CheckAuthCallback func(r *http.Request) (string, error)

type CheckServerMsgCallback

type CheckServerMsgCallback func(w http.ResponseWriter, r *http.Request) error

type Server

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

WebSocket 服务器实现.

func GetWebsocketSingleton

func GetWebsocketSingleton() *Server

func (*Server) Close

func (s *Server) Close()

func (*Server) HttpHandler

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

func (*Server) SetState

func (s *Server) SetState(status ServerState)

func (*Server) Start

func (s *Server) Start()

func (*Server) Stop

func (s *Server) Stop()

type ServerState

type ServerState string
const (
	SERVER_STATE_STARTING ServerState = "starting"
	SERVER_STATE_RUNNING  ServerState = "running"
	SERVER_STATE_CLOSING  ServerState = "closing"
	SERVER_STATE_STOP     ServerState = "stop"
)

type WebSocketConnect

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

func NewWebSocketConnect

func NewWebSocketConnect(conn *websocket.Conn) *WebSocketConnect

func (*WebSocketConnect) Close

func (p *WebSocketConnect) Close()

func (*WebSocketConnect) ConnectId

func (p *WebSocketConnect) ConnectId() string

func (*WebSocketConnect) LocalAddr

func (s *WebSocketConnect) LocalAddr() string

func (*WebSocketConnect) Read

func (p *WebSocketConnect) Read() ([]byte, error)

func (*WebSocketConnect) RemoteAddr

func (s *WebSocketConnect) RemoteAddr() string

func (*WebSocketConnect) Write

func (p *WebSocketConnect) Write(data []byte) error

Jump to

Keyboard shortcuts

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