client

package
v2.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2024 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	component.Base
	// contains filtered or unexported fields
}

func NewClient

func NewClient(opts ...Option) *Client

func (*Client) Destroy

func (c *Client) Destroy()

Destroy 销毁组件

func (*Client) Init

func (c *Client) Init()

Init 初始化节点

func (*Client) Name

func (c *Client) Name() string

Name 组件名称

func (*Client) Proxy

func (c *Client) Proxy() *Proxy

Proxy 获取节点代理

func (*Client) Start

func (c *Client) Start()

Start 启动组件

type Conn added in v2.1.0

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

func (*Conn) Bind added in v2.1.0

func (c *Conn) Bind(uid int64)

Bind 绑定用户ID

func (*Conn) Close added in v2.1.0

func (c *Conn) Close() error

Close 关闭连接

func (*Conn) DelAttr added in v2.1.0

func (c *Conn) DelAttr(key any)

DelAttr 删除属性值

func (*Conn) GetAttr added in v2.1.0

func (c *Conn) GetAttr(key any) value.Value

GetAttr 获取属性值

func (*Conn) ID added in v2.1.0

func (c *Conn) ID() int64

ID 获取连接ID

func (*Conn) LocalAddr added in v2.1.0

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

LocalAddr 获取本地地址

func (*Conn) LocalIP added in v2.1.0

func (c *Conn) LocalIP() (string, error)

LocalIP 获取本地IP

func (*Conn) Push added in v2.1.0

func (c *Conn) Push(message *cluster.Message) error

Push 推送消息

func (*Conn) RemoteAddr added in v2.1.0

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

RemoteAddr 获取远端地址

func (*Conn) RemoteIP added in v2.1.0

func (c *Conn) RemoteIP() (string, error)

RemoteIP 获取远端IP

func (*Conn) SetAttr added in v2.1.0

func (c *Conn) SetAttr(key, value any)

SetAttr 设置属性值

func (*Conn) UID added in v2.1.0

func (c *Conn) UID() int64

UID 获取用户ID

func (*Conn) Unbind added in v2.1.0

func (c *Conn) Unbind()

Unbind 解绑用户ID

type Context

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

func (*Context) CID

func (c *Context) CID() int64

CID 获取连接ID

func (*Context) Conn added in v2.1.0

func (c *Context) Conn() *Conn

Conn 获取连接

func (*Context) Context

func (c *Context) Context() context.Context

Context 获取上线文

func (*Context) Data

func (c *Context) Data() interface{}

Data 获取消息数据

func (*Context) Parse

func (c *Context) Parse(v interface{}) (err error)

Parse 解析消息

func (*Context) Route

func (c *Context) Route() int32

Route 获取消息路由

func (*Context) Seq

func (c *Context) Seq() int32

Seq 获取消息序列号

func (*Context) UID

func (c *Context) UID() int64

UID 获取用户ID

type DialOption added in v2.1.0

type DialOption func(o *dialOptions)

func WithConnAttr added in v2.1.0

func WithConnAttr(key string, value any) DialOption

WithConnAttr 设置连接属性

func WithDialAddr added in v2.1.0

func WithDialAddr(addr string) DialOption

WithDialAddr 设置拨号地址

type EventHandler

type EventHandler func(conn *Conn)

type HookHandler added in v2.1.0

type HookHandler func(proxy *Proxy)

type Option

type Option func(o *options)

func WithClient

func WithClient(client network.Client) Option

WithClient 设置客户端

func WithCodec

func WithCodec(codec encoding.Codec) Option

WithCodec 设置编解码器

func WithContext

func WithContext(ctx context.Context) Option

WithContext 设置上下文

func WithEncryptor

func WithEncryptor(encryptor crypto.Encryptor) Option

WithEncryptor 设置消息加密器

func WithID

func WithID(id string) Option

WithID 设置实例ID

func WithName

func WithName(name string) Option

WithName 设置实例名称

func WithTimeout

func WithTimeout(timeout time.Duration) Option

WithTimeout 设置RPC调用超时时间

type Proxy

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

func (*Proxy) AddEventListener

func (p *Proxy) AddEventListener(event cluster.Event, handler EventHandler)

AddEventListener 添加事件监听器

func (*Proxy) AddHookListener added in v2.1.0

func (p *Proxy) AddHookListener(hook cluster.Hook, handler HookHandler)

AddHookListener 添加钩子监听器

func (*Proxy) AddRouteHandler

func (p *Proxy) AddRouteHandler(route int32, handler RouteHandler)

AddRouteHandler 添加路由处理器

func (*Proxy) Client added in v2.1.0

func (p *Proxy) Client() network.Client

Client 获取客户端

func (*Proxy) Dial added in v2.1.0

func (p *Proxy) Dial(opts ...DialOption) (*Conn, error)

Dial 拨号

func (*Proxy) ID added in v2.1.0

func (p *Proxy) ID() string

ID 获取客户端ID

func (*Proxy) Name added in v2.1.0

func (p *Proxy) Name() string

Name 获取客户端名称

func (*Proxy) SetDefaultRouteHandler

func (p *Proxy) SetDefaultRouteHandler(handler RouteHandler)

SetDefaultRouteHandler 设置默认路由处理器,所有未注册的路由均走默认路由处理器

type RouteHandler

type RouteHandler func(ctx *Context)

Jump to

Keyboard shortcuts

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