server

package
v1.1.7 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2020 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type After added in v1.1.1

type After func(conn *WebSocket, receive *lemo.Receive) exception.Error

type Before added in v1.1.1

type Before func(conn *WebSocket, receive *lemo.Receive) (lemo.Context, exception.Error)

type Middle

type Middle func(conn *WebSocket, receive *lemo.ReceivePackage)

type RouteHandler

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

func (*RouteHandler) Route

func (handler *RouteHandler) Route(path string) *route

type Router

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

func (*Router) GetAllRouters

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

func (*Router) Group

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

func (*Router) Route

func (router *Router) Route(path string) *route

func (*Router) SetGlobalAfter added in v1.1.1

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

func (*Router) SetGlobalBefore added in v1.1.1

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

type Server

type Server struct {

	// Host 服务Host
	Name string
	Host string
	// Port 服务端口
	Port int
	// IP
	IP string
	// Protocol 协议
	TLS bool
	// TLS FILE
	CertFile string
	// TLS KEY
	KeyFile string

	AutoBind bool

	OnClose   func(conn *WebSocket)
	OnMessage func(conn *WebSocket, messageType int, msg []byte)
	OnOpen    func(conn *WebSocket)
	OnError   func(err exception.Error)
	OnSuccess func()

	HeartBeatTimeout  int
	HeartBeatInterval int
	HandshakeTimeout  int
	ReadBufferSize    int
	WriteBufferSize   int
	WaitQueueSize     int
	CheckOrigin       func(r *http.Request) bool
	Path              string

	PingHandler func(connection *WebSocket) func(appData string) error

	PongHandler func(connection *WebSocket) func(appData string) error

	Protocol websocket2.Protocol
	// contains filtered or unexported fields
}

func (*Server) CheckPath

func (socket *Server) CheckPath(p1 string, p2 string) bool

func (*Server) Close

func (socket *Server) Close(fd uint32) error

func (*Server) Emit

func (socket *Server) Emit(fd uint32, event []byte, body []byte, dataType int, protoType int) exception.Error

func (*Server) EmitAll

func (socket *Server) EmitAll(event []byte, body []byte, dataType int, protoType int) (int, int)

func (*Server) GetConnection

func (socket *Server) GetConnection(fd uint32) (*WebSocket, bool)

func (*Server) GetConnections

func (socket *Server) GetConnections() chan *WebSocket

func (*Server) GetConnectionsCount

func (socket *Server) GetConnectionsCount() uint32

func (*Server) GetRouter

func (socket *Server) GetRouter() *Router

func (*Server) Json

func (socket *Server) Json(fd uint32, msg lemo.JsonPackage) exception.Error

func (*Server) JsonAll

func (socket *Server) JsonAll(msg lemo.JsonPackage) (int, int)

func (*Server) JsonEmit

func (socket *Server) JsonEmit(fd uint32, msg lemo.JsonPackage) exception.Error

func (*Server) JsonEmitAll

func (socket *Server) JsonEmitAll(msg lemo.JsonPackage) (int, int)

func (*Server) LocalAddr added in v1.1.1

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

func (*Server) ProtoBufEmit

func (socket *Server) ProtoBufEmit(fd uint32, msg lemo.ProtoBufPackage) exception.Error

func (*Server) ProtoBufEmitAll

func (socket *Server) ProtoBufEmitAll(msg lemo.ProtoBufPackage) (int, int)

func (*Server) Push

func (socket *Server) Push(fd uint32, messageType int, msg []byte) exception.Error

Push 发送消息

func (*Server) Ready

func (socket *Server) Ready()

func (*Server) ServeHTTP

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

func (*Server) SetRouter

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

func (*Server) Shutdown

func (socket *Server) Shutdown()

func (*Server) Start

func (socket *Server) Start()

Start Http

func (*Server) Use

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

type WebSocket

type WebSocket struct {
	FD       uint32
	Conn     *websocket.Conn
	Server   *Server
	Response http.ResponseWriter
	Request  *http.Request
	Context  lemo.Context
}

WebSocket WebSocket

func (*WebSocket) ClientIP

func (conn *WebSocket) ClientIP() string

func (*WebSocket) Close

func (conn *WebSocket) Close() error

func (*WebSocket) Emit

func (conn *WebSocket) Emit(event []byte, body []byte, dataType int, protoType int) exception.Error

func (*WebSocket) Host

func (conn *WebSocket) Host() string

func (*WebSocket) Json

func (conn *WebSocket) Json(msg lemo.JsonPackage) exception.Error

func (*WebSocket) JsonEmit

func (conn *WebSocket) JsonEmit(msg lemo.JsonPackage) exception.Error

func (*WebSocket) ProtoBufEmit

func (conn *WebSocket) ProtoBufEmit(msg lemo.ProtoBufPackage) exception.Error

func (*WebSocket) Push

func (conn *WebSocket) Push(messageType int, msg []byte) exception.Error

Jump to

Keyboard shortcuts

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