server

package
v0.0.0-...-ebe959f Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Conn

type Conn interface {
	Host() string
	ClientIP() string
	Ping() error
	Pong() error
	Close() error
	Write(msg []byte) (int, error)
	FD() int64
	SetFD(fd int64)
	LastPing() time.Time
	SetLastPing(t time.Time)
	Name() string
	SetName(name string)
	Conn() net.Conn
	SetDeadline(t time.Time) error
	socket.Packer
}

type Middle

type Middle router.Middle[*socket.Stream[Conn]]

type Server

type Server[T any] struct {
	Name string
	Addr string
	// TLS FILE
	CertFile string
	// TLS KEY
	KeyFile string
	// TLS
	TLSConfig *tls.Config

	OnClose     func(conn Conn)
	OnMessage   func(conn Conn, msg []byte)
	OnOpen      func(conn Conn)
	OnError     func(stream *socket.Stream[Conn], err error)
	OnException func(err error)
	OnSuccess   func()
	OnUnknown   func(conn Conn, message []byte, next Middle)

	HeartBeatTimeout  time.Duration
	HeartBeatInterval time.Duration
	DailTimeout       time.Duration

	ReadBufferSize  int
	WriteBufferSize int

	PingHandler func(conn Conn) func(data string) error
	PongHandler func(conn Conn) func(data string) error
	Protocol    protocol.Protocol
	// contains filtered or unexported fields
}

func (*Server[T]) Conn

func (s *Server[T]) Conn(fd int64) (Conn, error)

func (*Server[T]) ConnLen

func (s *Server[T]) ConnLen() int

func (*Server[T]) GetDailTimeout

func (s *Server[T]) GetDailTimeout() time.Duration

func (*Server[T]) GetRouter

func (s *Server[T]) GetRouter() *router.Router[*socket.Stream[Conn], T]

func (*Server[T]) LocalAddr

func (s *Server[T]) LocalAddr() net.Addr

func (*Server[T]) Range

func (s *Server[T]) Range(fn func(conn Conn))

func (*Server[T]) Ready

func (s *Server[T]) Ready()

func (*Server[T]) Sender

func (s *Server[T]) Sender(fd int64) (socket.Emitter[Conn], error)

func (*Server[T]) SetRouter

func (s *Server[T]) SetRouter(router *router.Router[*socket.Stream[Conn], T]) *Server[T]

func (*Server[T]) Shutdown

func (s *Server[T]) Shutdown() error

func (*Server[T]) Start

func (s *Server[T]) Start()

func (*Server[T]) Use

func (s *Server[T]) Use(middle ...func(Middle) Middle)

Jump to

Keyboard shortcuts

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