server

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2022 License: Apache-2.0 Imports: 17 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type After

type After func(conn *Conn, stream *socket.Stream) error

type Before

type Before func(conn *Conn, stream *socket.Stream) error

type Conn

type Conn struct {
	Name     string
	FD       int64
	Conn     *websocket.Conn
	LastPing time.Time
	Server   *Server
	Response http.ResponseWriter
	Request  *http.Request
	// contains filtered or unexported fields
}

func (*Conn) ClientIP

func (c *Conn) ClientIP() string

func (*Conn) Close

func (c *Conn) Close() error

func (*Conn) Emit

func (c *Conn) Emit(pack socket.Pack) error

func (*Conn) Host

func (c *Conn) Host() string

func (*Conn) JsonEmit

func (c *Conn) JsonEmit(msg socket.JsonPack) error

func (*Conn) Ping

func (c *Conn) Ping() error

func (*Conn) Pong

func (c *Conn) Pong() error

func (*Conn) ProtoBufEmit

func (c *Conn) ProtoBufEmit(msg socket.ProtoBufPack) error

func (*Conn) Push

func (c *Conn) Push(msg []byte) error

func (*Conn) Write

func (c *Conn) Write(messageType int, msg []byte) (int, error)

type Middle

type Middle func(conn *Conn, stream *socket.Stream)

type RouteHandler

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

func (*RouteHandler) Remove

func (rh *RouteHandler) Remove(path ...string)

func (*RouteHandler) Route

func (rh *RouteHandler) Route(path ...string) *route

type Router

type Router struct {
	StrictMode bool
	// contains filtered or unexported fields
}

func (*Router) GetAllRouters

func (r *Router) GetAllRouters() []*node

func (*Router) Group

func (r *Router) Group(path ...string) *group

func (*Router) Remove

func (r *Router) Remove(path ...string)

func (*Router) Route

func (r *Router) Route(path ...string) *route

func (*Router) SetGlobalAfter

func (r *Router) SetGlobalAfter(after ...After)

func (*Router) SetGlobalBefore

func (r *Router) SetGlobalBefore(before ...Before)

type Server

type Server struct {
	Name string
	// Host 服务Host
	Addr string
	// TLS FILE
	CertFile string
	// TLS KEY
	KeyFile string

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

	HeartBeatTimeout  time.Duration
	HeartBeatInterval time.Duration
	HandshakeTimeout  time.Duration

	ReadBufferSize  int
	WriteBufferSize int
	CheckOrigin     func(r *http.Request) bool

	PingHandler func(conn *Conn) func(appData string) error
	PongHandler func(conn *Conn) func(appData string) error
	Protocol    websocket2.Protocol
	// contains filtered or unexported fields
}

func (*Server) Close

func (s *Server) Close(fd int64) error

func (*Server) Emit

func (s *Server) Emit(fd int64, pack socket.Pack) error

func (*Server) EmitAll

func (s *Server) EmitAll(pack socket.Pack) (int, int)

func (*Server) GetConnection

func (s *Server) GetConnection(fd int64) (*Conn, bool)

func (*Server) GetConnections

func (s *Server) GetConnections() chan *Conn

func (*Server) GetConnectionsCount

func (s *Server) GetConnectionsCount() int

func (*Server) GetRouter

func (s *Server) GetRouter() *Router

func (*Server) JsonEmit

func (s *Server) JsonEmit(fd int64, pack socket.JsonPack) error

func (*Server) JsonEmitAll

func (s *Server) JsonEmitAll(pack socket.JsonPack) (int, int)

func (*Server) LocalAddr

func (s *Server) LocalAddr() net.Addr

func (*Server) ProtoBufEmit

func (s *Server) ProtoBufEmit(fd int64, pack socket.ProtoBufPack) error

func (*Server) ProtoBufEmitAll

func (s *Server) ProtoBufEmitAll(msg socket.ProtoBufPack) (int, int)

func (*Server) Push

func (s *Server) Push(fd int64, msg []byte) error

func (*Server) Ready

func (s *Server) Ready()

func (*Server) ServeHTTP

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

func (*Server) SetRouter

func (s *Server) SetRouter(router *Router) *Server

func (*Server) Shutdown

func (s *Server) Shutdown() error

func (*Server) Start

func (s *Server) Start()

func (*Server) Use

func (s *Server) Use(middle ...func(next Middle) Middle)

Jump to

Keyboard shortcuts

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