client

package
v0.0.0-...-325de3d Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2021 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Channel

type Channel struct {
	ChannelID   string
	ChannelType uint8
}

Channel Channel

func NewChannel

func NewChannel(channelID string, channelType uint8) *Channel

NewChannel 创建频道

type Client

type Client struct {
	limlog.Log
	// contains filtered or unexported fields
}

Client 狸猫客户端

func New

func New(addr string, opts ...Option) *Client

New 创建客户端

func (*Client) Connect

func (c *Client) Connect() error

Connect 连接到IM

func (*Client) Disconnect

func (c *Client) Disconnect()

Disconnect 断开IM

func (*Client) Flush

func (c *Client) Flush() error

Flush Flush

func (*Client) GetOptions

func (c *Client) GetOptions() *Options

GetOptions GetOptions

func (*Client) GetRecvMsgCount

func (c *Client) GetRecvMsgCount() int64

GetRecvMsgCount GetRecvMsgCount

func (*Client) GetSendFailMsgCount

func (c *Client) GetSendFailMsgCount() int64

GetSendFailMsgCount GetSendFailMsgCount

func (*Client) GetSendMsgBytes

func (c *Client) GetSendMsgBytes() int64

GetSendMsgBytes 获取已发送字节数

func (*Client) SendMessage

func (c *Client) SendMessage(channel *Channel, payload []byte, opt ...SendOption) error

SendMessage 发送消息

func (*Client) SendMessageSync

func (c *Client) SendMessageSync(ctx context.Context, channel *Channel, payload []byte) (*lmproto.SendackPacket, error)

SendMessageSync 同步发送

func (*Client) SetOnClose

func (c *Client) SetOnClose(onClose OnClose)

SetOnClose 设置关闭事件

func (*Client) SetOnRecv

func (c *Client) SetOnRecv(onRecv OnRecv)

SetOnRecv 设置收消息事件

func (*Client) SetOnSendack

func (c *Client) SetOnSendack(onSendack OnSendack)

SetOnSendack 设置发送回执

type OnClose

type OnClose func()

OnClose 连接关闭

type OnRecv

type OnRecv func(recv *lmproto.RecvPacket) error

OnRecv 收到消息事件

type OnSendack

type OnSendack func(sendack *lmproto.SendackPacket)

OnSendack 发送消息回执

type Option

type Option func(*Options) error

Option 参数项

func WithAutoReconn

func WithAutoReconn(autoReconn bool) Option

WithAutoReconn WithAutoReconn

func WithProtoVersion

func WithProtoVersion(version uint8) Option

WithProtoVersion 设置协议版本

func WithToken

func WithToken(token string) Option

WithToken 用户token

func WithUID

func WithUID(uid string) Option

WithUID 用户UID

type Options

type Options struct {
	ProtoVersion uint8  // 协议版本
	UID          string // 用户uid
	Token        string // 连接IM的token
	AutoReconn   bool   //是否开启自动重连
}

Options Options

func NewOptions

func NewOptions() *Options

NewOptions 创建默认配置

type SendOption

type SendOption func(*SendOptions) error

SendOption 参数项

func SendOptionWithFlush

func SendOptionWithFlush(flush bool) SendOption

SendOptionWithFlush 是否 io flush

func SendOptionWithNoPersist

func SendOptionWithNoPersist(noPersist bool) SendOption

SendOptionWithNoPersist 是否不存储

func SendOptionWithRedDot

func SendOptionWithRedDot(redDot bool) SendOption

SendOptionWithRedDot 是否显示红点

func SendOptionWithSyncOnce

func SendOptionWithSyncOnce(syncOnce bool) SendOption

SendOptionWithSyncOnce 是否只同步一次(写模式)

type SendOptions

type SendOptions struct {
	NoPersist bool // 是否不存储 默认 false
	SyncOnce  bool // 是否同步一次(写模式) 默认 false
	Flush     bool // 是否io flush 默认true
	RedDot    bool // 是否显示红点 默认true
}

SendOptions SendOptions

func NewSendOptions

func NewSendOptions() *SendOptions

NewSendOptions NewSendOptions

Jump to

Keyboard shortcuts

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