 Documentation
      ¶
      Documentation
      ¶
    
    
  
    
      Index ¶
- Variables
- func Reconnect(client *Client) error
- type Client
- func (c *Client) Close(err error) <-chan struct{}
- func (c *Client) Closed() <-chan struct{}
- func (c *Client) GetEndpoint() string
- func (c *Client) GetFutures() concurrent.IFutures
- func (c *Client) GetLocalAddr() net.Addr
- func (c *Client) GetLogger() *zap.SugaredLogger
- func (c *Client) GetRemoteAddr() net.Addr
- func (c *Client) GetSessionId() uid.Id
- func (c *Client) GetToken() string
- func (c *Client) RecvDataChan() <-chan binaryutil.RecycleBytes
- func (c *Client) RecvEventChan() <-chan transport.IEvent
- func (c *Client) RequestTime(ctx context.Context) async.AsyncRetT[*ResponseTime]
- func (c *Client) SendData(data []byte) error
- func (c *Client) SendDataChan() chan<- binaryutil.RecycleBytes
- func (c *Client) SendEvent(event transport.IEvent) error
- func (c *Client) SendEventChan() chan<- transport.IEvent
- func (c *Client) String() string
- func (c *Client) WatchData(ctx context.Context, handler RecvDataHandler) IWatcher
- func (c *Client) WatchEvent(ctx context.Context, handler RecvEventHandler) IWatcher
 
- type ClientOptions
- type IWatcher
- type NetProtocol
- type RecvDataHandler
- type RecvEventHandler
- type ResponseTime
Constants ¶
This section is empty.
Variables ¶
      View Source
      
  
    var ( ErrReconnectFailed = errors.New("cli: reconnect failed") ErrInactiveTimeout = errors.New("cli: inactive timeout") )
      View Source
      
  
var With _Option
    Functions ¶
Types ¶
type Client ¶
Client 客户端
func Connect ¶
func Connect(ctx context.Context, endpoint string, settings ...option.Setting[ClientOptions]) (*Client, error)
Connect 连接服务端
func (*Client) GetFutures ¶
func (c *Client) GetFutures() concurrent.IFutures
GetFutures 获取异步模型Future控制器
func (*Client) GetLogger ¶ added in v0.1.36
func (c *Client) GetLogger() *zap.SugaredLogger
GetLogger 获取logger
func (*Client) RecvDataChan ¶
func (c *Client) RecvDataChan() <-chan binaryutil.RecycleBytes
RecvDataChan 接收数据的channel
func (*Client) RecvEventChan ¶
RecvEventChan 接收自定义事件的channel
func (*Client) RequestTime ¶
RequestTime 请求对端同步时间
func (*Client) SendDataChan ¶
func (c *Client) SendDataChan() chan<- binaryutil.RecycleBytes
SendDataChan 发送数据的channel
func (*Client) SendEventChan ¶
SendEventChan 发送自定义事件的channel
func (*Client) WatchData ¶
func (c *Client) WatchData(ctx context.Context, handler RecvDataHandler) IWatcher
WatchData 监听数据
func (*Client) WatchEvent ¶
func (c *Client) WatchEvent(ctx context.Context, handler RecvEventHandler) IWatcher
WatchEvent 监听自定义事件
type ClientOptions ¶
type ClientOptions struct {
	NetProtocol                 NetProtocol                  // 使用的网络协议(TCP/WebSocket)
	TCPNoDelay                  *bool                        // TCP的NoDelay选项,nil表示使用系统默认值
	TCPQuickAck                 *bool                        // TCP的QuickAck选项,nil表示使用系统默认值
	TCPRecvBuf                  *int                         // TCP的RecvBuf大小(字节)选项,nil表示使用系统默认值
	TCPSendBuf                  *int                         // TCP的SendBuf大小(字节)选项,nil表示使用系统默认值
	TCPLinger                   *int                         // TCP的PLinger选项,nil表示使用系统默认值
	WebSocketOrigin             string                       // WebSocket的Origin地址,不填将会自动生成
	TLSConfig                   *tls.Config                  // TLS配置,nil表示不使用TLS加密链路
	IOTimeout                   time.Duration                // 网络io超时时间
	IORetryTimes                int                          // 网络io超时后的重试次数
	IOBufferCap                 int                          // 网络io缓存容量(字节)
	DecoderMsgCreator           gtp.IMsgCreator              // 消息包解码器的消息构建器
	EncCipherSuite              gtp.CipherSuite              // 加密通信中的密码学套件
	EncSignatureAlgorithm       gtp.SignatureAlgorithm       // 加密通信中的签名算法
	EncSignaturePrivateKey      crypto.PrivateKey            // 加密通信中,签名用的私钥
	EncVerifyServerSignature    bool                         // 加密通信中,是否验证服务端签名
	EncVerifySignaturePublicKey crypto.PublicKey             // 加密通信中,验证服务端签名用的公钥
	Compression                 gtp.Compression              // 通信中的压缩函数
	CompressedSize              int                          // 通信中启用压缩阀值(字节),<=0表示不开启
	AutoReconnect               bool                         // 开启自动重连
	AutoReconnectInterval       time.Duration                // 自动重连的时间间隔
	AutoReconnectRetryTimes     int                          // 自动重连的重试次数,<=0表示无限重试
	InactiveTimeout             time.Duration                // 连接不活跃后的超时时间,开启自动重连后无效
	SendDataChan                chan binaryutil.RecycleBytes // 发送数据的channel
	RecvDataChan                chan binaryutil.RecycleBytes // 接收数据的channel
	RecvDataChanRecyclable      bool                         // 接收数据的channel中是否使用可回收字节对象
	SendEventChan               chan transport.IEvent        // 发送自定义事件的channel
	RecvEventChan               chan transport.IEvent        // 接收自定义事件的channel
	RecvDataHandler             RecvDataHandler              // 接收的数据的处理器
	RecvEventHandler            RecvEventHandler             // 接收的自定义事件的处理器
	FutureTimeout               time.Duration                // 异步模型Future超时时间
	AuthUserId                  string                       // 鉴权userid
	AuthToken                   string                       // 鉴权token
	AuthExtensions              []byte                       // 鉴权extensions
	ZapLogger                   *zap.Logger                  // zap日志
}
    type IWatcher ¶ added in v0.1.36
type IWatcher interface {
	context.Context
	Terminate() <-chan struct{}
	Terminated() <-chan struct{}
}
    IWatcher 监听器
type NetProtocol ¶ added in v0.1.40
type NetProtocol int32
const ( TCP NetProtocol = iota WebSocket )
type RecvDataHandler ¶
type RecvDataHandler = generic.DelegateFunc1[[]byte, error]
type RecvEventHandler ¶
type RecvEventHandler = transport.EventHandler
 Click to show internal directories. 
   Click to hide internal directories.