client

package
v2.4.2 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2025 License: MIT Imports: 20 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

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

func (*Conn) Bind

func (c *Conn) Bind(uid int64)

Bind 绑定用户ID

func (*Conn) Close

func (c *Conn) Close() error

Close 关闭连接

func (*Conn) DelAttr

func (c *Conn) DelAttr(key any)

DelAttr 删除属性值

func (*Conn) GetAttr

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

GetAttr 获取属性值

func (*Conn) ID

func (c *Conn) ID() int64

ID 获取连接ID

func (*Conn) LocalAddr

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

LocalAddr 获取本地地址

func (*Conn) LocalIP

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

LocalIP 获取本地IP

func (*Conn) Push

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

Push 推送消息

func (*Conn) RemoteAddr

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

RemoteAddr 获取远端地址

func (*Conn) RemoteIP

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

RemoteIP 获取远端IP

func (*Conn) SetAttr

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

SetAttr 设置属性值

func (*Conn) UID

func (c *Conn) UID() int64

UID 获取用户ID

func (*Conn) Unbind

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

func (c *Context) Conn() *Conn

Conn 获取连接

func (*Context) Context

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

Context 获取上线文

func (*Context) Data

func (c *Context) Data() any

Data 获取消息数据

func (*Context) Parse

func (c *Context) Parse(v any) (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

type DialOption func(o *dialOptions)

func WithConnAttr

func WithConnAttr(key string, value any) DialOption

WithConnAttr 设置连接属性

func WithDialAddr

func WithDialAddr(addr string) DialOption

WithDialAddr 设置拨号地址

type EventHandler

type EventHandler func(conn *Conn)

type HookHandler

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

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

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

Client 获取客户端

func (*Proxy) Dial

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

Dial 拨号

func (*Proxy) ID

func (p *Proxy) ID() string

ID 获取客户端ID

func (*Proxy) Name

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