client

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: 15 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(c *Client, receive *lemo.Receive) exception.Error

type Before added in v1.1.1

type Before func(c *Client, receive *lemo.Receive) (lemo.Context, exception.Error)

type Client

type Client struct {
	// 服务器信息
	Name   string
	Scheme string
	Host   string
	IP     string
	Port   int
	Path   string

	// 客户端信息
	Conn              *websocket.Conn
	Response          *http.Response
	AutoHeartBeat     bool
	HeartBeatTimeout  int
	HeartBeatInterval int
	HeartBeat         func(c *Client) error
	Reconnect         bool
	ReconnectInterval int
	WriteBufferSize   int
	ReadBufferSize    int
	HandshakeTimeout  int

	// 消息处理
	OnOpen    func(c *Client)
	OnClose   func(c *Client)
	OnMessage func(c *Client, messageType int, msg []byte)
	OnError   func(err exception.Error)
	OnSuccess func()
	Status    bool

	Context lemo.Context

	PingHandler func(c *Client) func(appData string) error

	PongHandler func(c *Client) func(appData string) error

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

func (*Client) Close

func (client *Client) Close() error

func (*Client) Connect

func (client *Client) Connect()

Connect 连接服务器

func (*Client) Emit

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

func (*Client) GetRouter

func (client *Client) GetRouter() *Router

func (*Client) Json

func (client *Client) Json(msg lemo.JsonPackage) exception.Error

func (*Client) JsonEmit

func (client *Client) JsonEmit(msg lemo.JsonPackage) exception.Error

func (*Client) LocalAddr added in v1.1.1

func (client *Client) LocalAddr() net.Addr

func (*Client) ProtoBufEmit

func (client *Client) ProtoBufEmit(msg lemo.ProtoBufPackage) exception.Error

func (*Client) Push

func (client *Client) Push(messageType int, message []byte) exception.Error

Push 发送消息

func (*Client) RemoteAddr added in v1.1.1

func (client *Client) RemoteAddr() net.Addr

func (*Client) SetRouter

func (client *Client) SetRouter(router *Router) *Client

func (*Client) Use

func (client *Client) Use(middle ...func(Middle) Middle)

type Middle

type Middle func(c *Client, 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)

Jump to

Keyboard shortcuts

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