listener

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2025 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EncryptionTypeNone      uint = 0
	EncryptionTypeBase64    uint = 1
	EncryptionTypeAESGCM    uint = 2
	EncryptionTypeAESGCMRaw uint = 3
)
View Source
const (
	ZaloManualClosure       int = 1000
	ZaloAbnormalClosure     int = 1006
	ZaloDuplicateConnection int = 3000
	ZaloKickConnection      int = 3003
)

Variables

This section is empty.

Functions

func New

func New(sc session.MutableContext, urls []string) (*listener, error)

Types

type BaseWSMessage

type BaseWSMessage = WSMessage[string]

type Buffers

type Buffers struct {
	Connected         int
	Disconnected      int
	Closed            int
	Error             int
	Message           int
	OldMessages       int
	Typing            int
	SeenMessages      int
	DeliveredMessages int
	Reaction          int
	OldReactions      int
	Undo              int
	UploadAttachment  int
	Friend            int
	Group             int
	CipherKey         int
}

type CloseInfo

type CloseInfo = websocketx.CloseInfo

type Listener

type Listener interface {
	Start(ctx context.Context, retryOnClose bool) error
	Stop()

	// Channels
	Connected() <-chan struct{}
	Disconnected() <-chan websocketx.CloseInfo
	Closed() <-chan websocketx.CloseInfo
	Error() <-chan error
	Message() <-chan model.Message
	OldMessages() <-chan model.OldMessages
	Reaction() <-chan model.Reaction
	OldReactions() <-chan model.OldReactions
	Typing() <-chan model.Typing
	// Zalo may sent duplicate delivered messages, based on number of online devices of recipients
	DeliveredMessages() <-chan []model.DeliveredMessage
	SeenMessages() <-chan []model.SeenMessage
	Undo() <-chan model.Undo
	UploadAttachment() <-chan model.UploadAttachment
	Friend() <-chan model.FriendEvent
	Group() <-chan model.GroupEvent
	CipherKey() <-chan string

	SendWS(ctx context.Context, payload WSPayload, requireID bool) error

	RequestOldMessages(ctx context.Context, threadType model.ThreadType, lastMsgID *string) error
	RequestOldReactions(ctx context.Context, threadType model.ThreadType, lastMsgID *string) error
}

type WSMessage

type WSMessage[T any] struct {
	Key          *string `json:"key"`
	Encrypt      uint    `json:"encrypt"`
	ErrorCode    int     `json:"error_code"`
	ErrorMessage string  `json:"error_message"`
	Data         T       `json:"data"`
}

type WSPayload

type WSPayload struct {
	Version uint8
	CMD     uint16
	SubCMD  uint8
	Data    map[string]any
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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