Documentation ¶
Index ¶
- Constants
- Variables
- func GenMsgIncr(userID string) string
- func IsNotification(conversationID string) bool
- type Compressor
- type ConnContext
- type Default
- func (d *Default) Close() error
- func (d *Default) Dial(urlStr string, requestHeader http.Header) (*http.Response, error)
- func (d *Default) IsNil() bool
- func (d *Default) LocalAddr() string
- func (d *Default) ReadMessage() (int, []byte, error)
- func (d *Default) SetPingHandler(handler PingPongHandler)
- func (d *Default) SetPongHandler(handler PingPongHandler)
- func (d *Default) SetReadDeadline(timeout time.Duration) error
- func (d *Default) SetReadLimit(limit int64)
- func (d *Default) SetWriteDeadline(timeout time.Duration) error
- func (d *Default) WriteMessage(messageType int, message []byte) error
- type Encoder
- type ExponentialRetry
- type GeneralWsReq
- type GeneralWsResp
- type GobEncoder
- type GzipCompressor
- type LongConn
- type LongConnMgr
- func (c *LongConnMgr) Close(ctx context.Context)
- func (c *LongConnMgr) GetBackground() bool
- func (c *LongConnMgr) GetConnectionStatus() int
- func (c *LongConnMgr) GetSubscribeUsersStatus(ctx context.Context) ([]*userPb.OnlineStatus, error)
- func (c *LongConnMgr) GetUserOnlinePlatformIDs(ctx context.Context, userIDs []string) (map[string][]int32, error)
- func (c *LongConnMgr) IsConnected() bool
- func (c *LongConnMgr) Run(ctx context.Context)
- func (c *LongConnMgr) SendReqWaitResp(ctx context.Context, m proto.Message, reqIdentifier int, resp proto.Message) error
- func (c *LongConnMgr) SetBackground(isBackground bool)
- func (c *LongConnMgr) SetConnectionStatus(status int)
- func (c *LongConnMgr) SubscribeUsersStatus(ctx context.Context, userIDs []string) ([]*userPb.OnlineStatus, error)
- func (c *LongConnMgr) UnsubscribeUserOnlinePlatformIDs(ctx context.Context, userIDs []string) error
- func (c *LongConnMgr) UnsubscribeUsersStatus(ctx context.Context, userIDs []string) error
- type Message
- type MsgSyncer
- type PingPongHandler
- type ReconnectStrategy
- type WsRespAsyn
- func (u *WsRespAsyn) AddCh(userID string) (string, chan *GeneralWsResp)
- func (u *WsRespAsyn) AddChByIncr(msgIncr string) chan *GeneralWsResp
- func (u *WsRespAsyn) DelCh(msgIncr string)
- func (u *WsRespAsyn) GetCh(msgIncr string) chan *GeneralWsResp
- func (u *WsRespAsyn) NotifyResp(ctx context.Context, wsResp GeneralWsResp) error
- func (u *WsRespAsyn) WaitResp(ctx context.Context, ch chan *GeneralWsResp, timeout int) (*GeneralWsResp, error)
Constants ¶
View Source
const ( WebSocket = iota Tcp )
View Source
const ( // MessageText is for UTF-8 encoded text messages like JSON. MessageText = iota + 1 // MessageBinary is for binary messages like protobufs. MessageBinary // CloseMessage denotes a close control message. The optional message // payload contains a numeric code and text. Use the FormatCloseMessage // function to format a close message payload. CloseMessage = 8 // PingMessage denotes a ping control message. The optional message payload // is UTF-8 encoded text. PingMessage = 9 // PongMessage denotes a pong control message. The optional message payload // is UTF-8 encoded text. PongMessage = 10 )
View Source
const ( DefaultNotConnect = iota Closed = iota + 1 Connecting Connected )
View Source
const (
SplitPullMsgNum = 100
)
Variables ¶
Functions ¶
func GenMsgIncr ¶
func IsNotification ¶
Types ¶
type Compressor ¶
type ConnContext ¶
type ConnContext struct {
RemoteAddr string
}
func (*ConnContext) Done ¶
func (c *ConnContext) Done() <-chan struct{}
func (*ConnContext) Err ¶
func (c *ConnContext) Err() error
func (*ConnContext) Value ¶
func (c *ConnContext) Value(key any) any
type Default ¶
type Default struct { ConnType int // contains filtered or unexported fields }
func NewWebSocket ¶
func (*Default) SetPingHandler ¶ added in v3.8.0
func (d *Default) SetPingHandler(handler PingPongHandler)
func (*Default) SetPongHandler ¶
func (d *Default) SetPongHandler(handler PingPongHandler)
func (*Default) SetReadLimit ¶
type ExponentialRetry ¶ added in v3.5.0
type ExponentialRetry struct {
// contains filtered or unexported fields
}
func NewExponentialRetry ¶ added in v3.5.0
func NewExponentialRetry() *ExponentialRetry
func (*ExponentialRetry) GetSleepInterval ¶ added in v3.5.0
func (rs *ExponentialRetry) GetSleepInterval() time.Duration
func (*ExponentialRetry) Reset ¶ added in v3.5.0
func (rs *ExponentialRetry) Reset()
type GeneralWsReq ¶
type GeneralWsResp ¶
type GobEncoder ¶
type GobEncoder struct { }
func NewGobEncoder ¶
func NewGobEncoder() *GobEncoder
func (*GobEncoder) Decode ¶
func (g *GobEncoder) Decode(encodeData []byte, decodeData interface{}) error
func (*GobEncoder) Encode ¶
func (g *GobEncoder) Encode(data interface{}) ([]byte, error)
type GzipCompressor ¶
type GzipCompressor struct {
// contains filtered or unexported fields
}
func NewGzipCompressor ¶
func NewGzipCompressor() *GzipCompressor
func (*GzipCompressor) CompressWithPool ¶ added in v3.8.0
func (g *GzipCompressor) CompressWithPool(rawData []byte) ([]byte, error)
func (*GzipCompressor) DeCompress ¶
func (g *GzipCompressor) DeCompress(compressedData []byte) ([]byte, error)
func (*GzipCompressor) DecompressWithPool ¶ added in v3.8.0
func (g *GzipCompressor) DecompressWithPool(compressedData []byte) ([]byte, error)
type LongConn ¶
type LongConn interface { // Close closes this connection. Close() error // WriteMessage writes a message to the connection. // messageType indicates the type of data and can be set to binary (2) or text (1). WriteMessage(messageType int, message []byte) error // ReadMessage reads a message from the connection. ReadMessage() (int, []byte, error) // SetReadDeadline sets the deadline for reading from the underlying network connection. // After a timeout, there will be an error in the writing process. SetReadDeadline(timeout time.Duration) error // SetWriteDeadline sets the deadline for writing to the connection. // After a timeout, there will be an error in the writing process. SetWriteDeadline(timeout time.Duration) error // Dial tries to establish a connection. // urlStr must include authentication arguments; requestHeader can control data compression. Dial(urlStr string, requestHeader http.Header) (*http.Response, error) // IsNil checks whether the current long connection is nil. IsNil() bool // SetReadLimit sets the maximum size for a message read from the peer in bytes. SetReadLimit(limit int64) // SetPingHandler sets the handler for ping messages. SetPingHandler(handler PingPongHandler) // SetPongHandler sets the handler for pong messages. SetPongHandler(handler PingPongHandler) // LocalAddr returns the local network address. LocalAddr() string }
type LongConnMgr ¶
type LongConnMgr struct { IsCompression bool Syncer *WsRespAsyn IsBackground bool // contains filtered or unexported fields }
func NewLongConnMgr ¶
func NewLongConnMgr(ctx context.Context, listener open_im_sdk_callback.OnConnListener, userOnline func(map[string][]int32), pushMsgAndMaxSeqCh, loginMgrCh chan common.Cmd2Value) *LongConnMgr
func (*LongConnMgr) Close ¶
func (c *LongConnMgr) Close(ctx context.Context)
func (*LongConnMgr) GetBackground ¶ added in v3.5.0
func (c *LongConnMgr) GetBackground() bool
func (*LongConnMgr) GetConnectionStatus ¶
func (c *LongConnMgr) GetConnectionStatus() int
func (*LongConnMgr) GetSubscribeUsersStatus ¶ added in v3.8.0
func (c *LongConnMgr) GetSubscribeUsersStatus(ctx context.Context) ([]*userPb.OnlineStatus, error)
func (*LongConnMgr) GetUserOnlinePlatformIDs ¶ added in v3.8.0
func (*LongConnMgr) IsConnected ¶
func (c *LongConnMgr) IsConnected() bool
func (*LongConnMgr) Run ¶
func (c *LongConnMgr) Run(ctx context.Context)
func (*LongConnMgr) SendReqWaitResp ¶
func (*LongConnMgr) SetBackground ¶
func (c *LongConnMgr) SetBackground(isBackground bool)
func (*LongConnMgr) SetConnectionStatus ¶ added in v3.5.0
func (c *LongConnMgr) SetConnectionStatus(status int)
func (*LongConnMgr) SubscribeUsersStatus ¶ added in v3.8.0
func (c *LongConnMgr) SubscribeUsersStatus(ctx context.Context, userIDs []string) ([]*userPb.OnlineStatus, error)
func (*LongConnMgr) UnsubscribeUserOnlinePlatformIDs ¶ added in v3.8.0
func (c *LongConnMgr) UnsubscribeUserOnlinePlatformIDs(ctx context.Context, userIDs []string) error
func (*LongConnMgr) UnsubscribeUsersStatus ¶ added in v3.8.0
func (c *LongConnMgr) UnsubscribeUsersStatus(ctx context.Context, userIDs []string) error
type Message ¶
type Message struct { Message GeneralWsReq Resp chan *GeneralWsResp }
type MsgSyncer ¶
type MsgSyncer struct { PushMsgAndMaxSeqCh chan common.Cmd2Value // channel for receiving push messages and the maximum SEQ number // contains filtered or unexported fields }
MsgSyncer is a central hub for message relay, responsible for sequential message gap pulling, handling network events, and managing app foreground and background events.
func NewMsgSyncer ¶
func NewMsgSyncer(ctx context.Context, conversationCh, PushMsgAndMaxSeqCh chan common.Cmd2Value, loginUserID string, longConnMgr *LongConnMgr, db db_interface.DataBase, syncTimes int) (*MsgSyncer, error)
NewMsgSyncer creates a new instance of the message synchronizer.
func (*MsgSyncer) DoListener ¶
DoListener Listen to the message pipe of the message synchronizer and process received and pushed messages
type PingPongHandler ¶ added in v3.8.0
type ReconnectStrategy ¶ added in v3.5.0
type WsRespAsyn ¶
type WsRespAsyn struct {
// contains filtered or unexported fields
}
func NewWsRespAsyn ¶
func NewWsRespAsyn() *WsRespAsyn
func (*WsRespAsyn) AddCh ¶
func (u *WsRespAsyn) AddCh(userID string) (string, chan *GeneralWsResp)
func (*WsRespAsyn) AddChByIncr ¶
func (u *WsRespAsyn) AddChByIncr(msgIncr string) chan *GeneralWsResp
func (*WsRespAsyn) DelCh ¶
func (u *WsRespAsyn) DelCh(msgIncr string)
func (*WsRespAsyn) GetCh ¶
func (u *WsRespAsyn) GetCh(msgIncr string) chan *GeneralWsResp
func (*WsRespAsyn) NotifyResp ¶
func (u *WsRespAsyn) NotifyResp(ctx context.Context, wsResp GeneralWsResp) error
write a unit test for this function
func (*WsRespAsyn) WaitResp ¶
func (u *WsRespAsyn) WaitResp(ctx context.Context, ch chan *GeneralWsResp, timeout int) (*GeneralWsResp, error)
Click to show internal directories.
Click to hide internal directories.