client

package
v2.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2022 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type After

type After func(client *Client, stream *socket.Stream) error

type Async

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

func (*Async) Emit

func (a *Async) Emit(pack socket.Pack) (*socket.Stream, error)

func (*Async) JsonEmit

func (a *Async) JsonEmit(pack socket.JsonPack) (*socket.Stream, error)

func (*Async) ProtoBufEmit

func (a *Async) ProtoBufEmit(pack socket.ProtoBufPack) (*socket.Stream, error)

type Before

type Before func(client *Client, stream *socket.Stream) error

type Client

type Client struct {
	Name string
	Addr string

	Conn     *Conn
	Response *http.Response

	HeartBeatTimeout  time.Duration
	HeartBeatInterval time.Duration
	ReconnectInterval time.Duration
	HeartBeat         func(c *Client) error

	WriteBufferSize int
	ReadBufferSize  int
	DailTimeout     time.Duration

	OnOpen         func(client *Client)
	OnClose        func(client *Client)
	OnMessage      func(client *Client, messageType int, msg []byte)
	OnError        func(err error)
	OnSuccess      func()
	OnReconnecting func()
	OnUnknown      func(conn *Client, message []byte, next Middle)

	PingHandler func(client *Client) func(appData string) error
	PongHandler func(client *Client) func(appData string) error

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

func (*Client) Async

func (c *Client) Async() *Async

func (*Client) Close

func (c *Client) Close() error

func (*Client) Connect

func (c *Client) Connect()

Connect 连接服务器

func (*Client) Emit

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

func (*Client) GetRouter

func (c *Client) GetRouter() *Router

func (*Client) JsonEmit

func (c *Client) JsonEmit(pack socket.JsonPack) error

func (*Client) LocalAddr

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

func (*Client) Ping

func (c *Client) Ping() error

func (*Client) Pong

func (c *Client) Pong() error

func (*Client) ProtoBufEmit

func (c *Client) ProtoBufEmit(pack socket.ProtoBufPack) error

func (*Client) Push

func (c *Client) Push(message []byte) error

func (*Client) RemoteAddr

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

func (*Client) SetRouter

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

func (*Client) Use

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

type Conn

type Conn struct {
	Conn     *websocket.Conn
	LastPong time.Time
	// contains filtered or unexported fields
}

func (*Conn) Close

func (c *Conn) Close() error

func (*Conn) LocalAddr

func (c *Conn) LocalAddr() net.Addr

func (*Conn) Read

func (c *Conn) Read() (int, []byte, error)

func (*Conn) RemoteAddr

func (c *Conn) RemoteAddr() net.Addr

func (*Conn) Write

func (c *Conn) Write(message []byte) error

type Middle

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

Jump to

Keyboard shortcuts

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