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) SetPongHandler(handler PongHandler)
- 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) 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)
- type Message
- type MsgSyncer
- type PongHandler
- 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) SetPongHandler ¶
func (d *Default) SetPongHandler(handler PongHandler)
func (*Default) SetReadLimit ¶
type ExponentialRetry ¶
type ExponentialRetry struct {
// contains filtered or unexported fields
}
func NewExponentialRetry ¶
func NewExponentialRetry() *ExponentialRetry
func (*ExponentialRetry) GetSleepInterval ¶
func (rs *ExponentialRetry) GetSleepInterval() time.Duration
func (*ExponentialRetry) Reset ¶
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) DeCompress ¶
func (g *GzipCompressor) DeCompress(compressedData []byte) ([]byte, error)
type LongConn ¶
type LongConn interface {
//Close this connection
Close() error
// WriteMessage Write message to connection,messageType means data type,can be set binary(2) and text(1).
WriteMessage(messageType int, message []byte) error
// ReadMessage Read message from connection.
ReadMessage() (int, []byte, error)
// SetReadDeadline sets the read deadline on the underlying network connection,
//after a read has timed out, will return an error.
SetReadDeadline(timeout time.Duration) error
// SetWriteDeadline sets to write deadline when send message,when read has timed out,will return error.
SetWriteDeadline(timeout time.Duration) error
// Dial Try to dial a connection,url must set auth args,header can control compress data
Dial(urlStr string, requestHeader http.Header) (*http.Response, error)
// IsNil Whether the connection of the current long connection is nil
IsNil() bool
// SetReadLimit sets the maximum size for a message read from the peer.bytes
SetReadLimit(limit int64)
SetPongHandler(handler PongHandler)
// 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, heartbeatCmdCh, pushMsgAndMaxSeqCh, loginMgrCh chan common.Cmd2Value) *LongConnMgr
func (*LongConnMgr) Close ¶
func (c *LongConnMgr) Close(ctx context.Context)
func (*LongConnMgr) GetBackground ¶
func (c *LongConnMgr) GetBackground() bool
func (*LongConnMgr) GetConnectionStatus ¶
func (c *LongConnMgr) GetConnectionStatus() int
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 ¶
func (c *LongConnMgr) SetConnectionStatus(status int)
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
}
The callback synchronization starts. The reconnection ends
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 PongHandler ¶
type ReconnectStrategy ¶
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.