Documentation ¶
Index ¶
- Constants
- Variables
- type Channel
- type Client
- func (c *Client) Close()
- func (c *Client) Connect() error
- func (c *Client) Flush() error
- func (c *Client) FlushTimeout(timeout time.Duration) (err error)
- func (c *Client) SendMessage(channel *Channel, payload []byte, opt ...SendOption) error
- func (c *Client) SetOnRecv(onRecv OnRecv)
- func (c *Client) SetOnSendack(onSendack OnSendack)
- type OnRecv
- type OnSendack
- type Option
- type Options
- type SendOption
- func SendOptionWithClientMsgNo(clientMsgNo string) SendOption
- func SendOptionWithFlush(flush bool) SendOption
- func SendOptionWithNoEncrypt(noEncrypt bool) SendOption
- func SendOptionWithNoPersist(noPersist bool) SendOption
- func SendOptionWithRedDot(redDot bool) SendOption
- func SendOptionWithSyncOnce(syncOnce bool) SendOption
- type SendOptions
- type Statistics
- type Status
Constants ¶
View Source
const ( DISCONNECTED = Status(iota) CONNECTED CLOSED RECONNECTING CONNECTING )
View Source
const (
STALE_CONNECTION = "stale connection"
)
Variables ¶
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { Statistics oklog.Log // contains filtered or unexported fields }
func (*Client) Flush ¶
Flush will perform a round trip to the server and return when it receives the internal reply.
func (*Client) FlushTimeout ¶
FlushTimeout allows a Flush operation to have an associated timeout.
func (*Client) SendMessage ¶
func (c *Client) SendMessage(channel *Channel, payload []byte, opt ...SendOption) error
func (*Client) SetOnSendack ¶
type OnSendack ¶
type OnSendack func(sendackPacket *okproto.SendackPacket)
type Options ¶
type Options struct { ProtoVersion uint8 // 协议版本 UID string // 用户uid Token string // 连接IM的token AutoReconn bool //是否开启自动重连 DefaultBufSize int // The size of the bufio reader/writer on top of the socket. // ReconnectBufSize is the size of the backing bufio during reconnect. // Once this has been exhausted publish operations will return an error. // Defaults to 8388608 bytes (8MB). ReconnectBufSize int // FlusherTimeout is the maximum time to wait for write operations // to the underlying connection to complete (including the flusher loop). FlusherTimeout time.Duration // Timeout sets the timeout for a Dial operation on a connection. Timeout time.Duration PingInterval time.Duration MaxPingCount int // 最大ping的次数 // ReconnectJitter sets the upper bound for a random delay added to // ReconnectWait during a reconnect when no TLS is used. ReconnectJitter time.Duration // ReconnectWait sets the time to backoff after attempting a reconnect // to a server that we were already connected to previously. ReconnectWait time.Duration }
Options Options
type SendOption ¶
type SendOption func(*SendOptions) error
SendOption 参数项
func SendOptionWithClientMsgNo ¶
func SendOptionWithClientMsgNo(clientMsgNo string) SendOption
SendOptionWithClientMsgNo 是否显示红点
func SendOptionWithFlush ¶
func SendOptionWithFlush(flush bool) SendOption
SendOptionWithFlush 是否 io flush
func SendOptionWithNoEncrypt ¶
func SendOptionWithNoEncrypt(noEncrypt bool) SendOption
SendOptionWithNoEncrypt 是否不需要加密
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 NoEncrypt bool // 是否不需要加密 ClientMsgNo string }
SendOptions SendOptions
type Statistics ¶
Click to show internal directories.
Click to hide internal directories.