Documentation
¶
Index ¶
- type Conn
- type Middle
- type Server
- func (s *Server[T]) Conn(fd int64) (Conn, error)
- func (s *Server[T]) ConnLen() int
- func (s *Server[T]) GetDailTimeout() time.Duration
- func (s *Server[T]) GetRouter() *router.Router[*socket.Stream[Conn], T]
- func (s *Server[T]) LocalAddr() net.Addr
- func (s *Server[T]) Range(fn func(conn Conn))
- func (s *Server[T]) Ready()
- func (s *Server[T]) Sender(fd int64) (socket.Emitter[Conn], error)
- func (s *Server[T]) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (s *Server[T]) SetRouter(router *router.Router[*socket.Stream[Conn], T]) *Server[T]
- func (s *Server[T]) Shutdown() error
- func (s *Server[T]) Start()
- func (s *Server[T]) Use(middle ...func(next Middle) Middle)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Conn ¶
type Conn interface {
Name() string
SetName(name string)
FD() int64
SetFD(int64)
Host() string
ClientIP() string
Ping() error
Pong() error
Write(messageType int, msg []byte) (int, error)
Close() error
SetLastPing(time.Time)
LastPing() time.Time
Conn() *websocket.Conn
Response() http.ResponseWriter
Request() *http.Request
SubProtocols() []string
SetDeadline(t time.Time) error
socket.Packer
}
type Server ¶
type Server[T any] struct { Name string // Host 服务Host Addr string // TLS FILE CertFile string // TLS KEY KeyFile string // TLS TLSConfig *tls.Config // Path Path string OnOpen func(conn Conn) OnMessage func(conn Conn, msg []byte) OnClose func(conn Conn) OnError func(stream *socket.Stream[Conn], err error) OnException func(err error) OnSuccess func() OnRaw func(w http.ResponseWriter, r *http.Request) OnUnknown func(conn Conn, message []byte, next Middle) HeartBeatTimeout time.Duration HeartBeatInterval time.Duration HandshakeTimeout time.Duration DailTimeout time.Duration ReadBufferSize int WriteBufferSize int SubProtocols []string CheckOrigin func(r *http.Request) bool PingHandler func(conn Conn) func(data string) error PongHandler func(conn Conn) func(data string) error ReadTimeout time.Duration WriteTimeout time.Duration IdleTimeout time.Duration ReadHeaderTimeout time.Duration MaxHeaderBytes int // contains filtered or unexported fields }
func (*Server[T]) GetDailTimeout ¶
Click to show internal directories.
Click to hide internal directories.