ws

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Testwg       sync.WaitGroup
	TestWSServer *Server
	TestHandlerC *TestWSHandler
	TestHandlerS *TestWSHandler
)

Functions

func Connect

func Connect(addr string, conf *anet.Conf, h anet.Handler, wg *sync.WaitGroup,
	onConnect anet.OnConnect, onDisconnect anet.OnDisconnect) anet.Conn

func NewTestWSHandler

func NewTestWSHandler(conf *alog.LogConf)

func NewWSServer

func NewWSServer(addr string, path string)

Types

type ClientConf

type ClientConf struct {
	URL                 string
	Path                string
	RetryIntervalMinSec uint32 `json:",default=5"`
	RetryIntervalMaxSec uint32 `json:",default=30"`
	Log                 alog.LogConf
}

type Connection

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

A Connction is related with one user When User reconnect, conn will re-related to connection

func WSConnect

func WSConnect(conf *ClientConf, h anet.Handler, wg *sync.WaitGroup,
	onConnect anet.OnConnect, onDisconnect anet.OnDisconnect) *Connection

func (*Connection) Close

func (c *Connection) Close()

func (*Connection) Lctx

func (c *Connection) Lctx() *alog.LogCtx

func (*Connection) Prefix

func (c *Connection) Prefix() string

func (*Connection) Send

func (c *Connection) Send(m *anet.Msg) error

func (*Connection) Suffix

func (c *Connection) Suffix() string

type CreateHandler

type CreateHandler func(*Connection) anet.Handler

type Server

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

func NewServer

func NewServer(c *ServerConf) *Server

func (*Server) RegisteHandler

func (s *Server) RegisteHandler(path string, ch CreateHandler)

func (*Server) Run

func (s *Server) Run(wg *sync.WaitGroup)

func (*Server) Stop

func (s *Server) Stop()

type ServerConf

type ServerConf struct {
	Addr string `json:",default=:8000"`
	Log  alog.LogConf
}

type TestWSHandler

type TestWSHandler struct {
	Wait           chan bool
	Conn           *Connection
	HandleResponse func(*anet.Msg)
	HandleRequest  func(*anet.Msg)
}

func (*TestWSHandler) OnMsg

func (th *TestWSHandler) OnMsg(c anet.Conn, m *anet.Msg)

Jump to

Keyboard shortcuts

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