sessionsv5

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2021 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrSessionsProviderNotFound = errors.New("Session: Session provider not found")
	ErrKeyNotAvailable          = errors.New("Session: not item found for key.")
)
View Source
var Default = "default"

Register makes a session provider available by the provided name. If a Register is called twice with the same name or if the driver is nil, it panics.

Functions

func Register

func Register(name string, provider SessionsProvider)

func SessionInit

func SessionInit(session string)

func Unregister

func Unregister(name string)

Types

type Ackmsg

type Ackmsg struct {
	// Message type of the messagev5 waiting for ack
	//等待ack消息的消息类型
	Mtype messagev5.MessageType

	// Current state of the ack-waiting messagev5
	//等待ack-waiting消息的当前状态
	State messagev5.MessageType

	// Packet ID of the messagev5. Every messagev5 that require ack'ing must have a valid
	// packet ID. Messages that have messagev5 I
	//消息的包ID。每个需要ack'ing的消息必须有一个有效的
	//数据包ID,包含消息I的消息
	Pktid uint16

	// Slice containing the messagev5 bytes
	//包含消息字节的片
	Msgbuf []byte

	// Slice containing the ack messagev5 bytes
	//包含ack消息字节的片
	Ackbuf []byte

	// When ack cycle completes, call this function
	//当ack循环完成时,调用这个函数
	OnComplete interface{}
}

type Ackqueue

type Ackqueue interface {
	Wait(msg messagev5.Message, onComplete interface{}) error
	Ack(msg messagev5.Message) error
	Acked() []Ackmsg
}

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

func NewManager

func NewManager(providerName string) (*Manager, error)

func (*Manager) Close

func (this *Manager) Close() error

func (*Manager) Count

func (this *Manager) Count() int

func (*Manager) Del

func (this *Manager) Del(id string)

func (*Manager) Get

func (this *Manager) Get(id string, cleanStart bool) (Session, error)

func (*Manager) New

func (this *Manager) New(id string, cleanStart bool) (Session, error)

func (*Manager) Save

func (this *Manager) Save(id string) error

type Session

type Session interface {
	Init(msg *messagev5.ConnectMessage, topics ...SessionInitTopic) error
	Update(msg *messagev5.ConnectMessage) error

	AddTopic(topic string, qos byte) error
	RemoveTopic(topic string) error
	Topics() ([]string, []byte, error)

	ID() string  // 客户端id
	IDs() []byte // 客户端id 字节类型的

	Cmsg() *messagev5.ConnectMessage
	Will() *messagev5.PublishMessage

	Pub1ack() Ackqueue
	Pub2in() Ackqueue
	Pub2out() Ackqueue
	Suback() Ackqueue
	Unsuback() Ackqueue
	Pingack() Ackqueue
	SessionExpand
}

type SessionExpand

type SessionExpand interface {
	ExpiryInterval() uint32
	Status() Status
	ClientId() string
	ReceiveMaximum() uint16
	MaxPacketSize() uint32
	TopicAliasMax() uint16
	RequestRespInfo() byte
	RequestProblemInfo() byte
	UserProperty() []string

	OfflineTime() int64

	SetExpiryInterval(uint32)
	SetStatus(Status)
	SetClientId(string)
	SetReceiveMaximum(uint16)
	SetMaxPacketSize(uint32)
	SetTopicAliasMax(uint16)
	SetRequestRespInfo(byte)
	SetRequestProblemInfo(byte)
	SetUserProperty([]string)

	SetOfflineTime(int64)

	SetWill(*messagev5.PublishMessage)
	SetSub(*messagev5.SubscribeMessage)
}

type SessionInitTopic

type SessionInitTopic struct {
	Topic string
	Qos   byte
}

type SessionsProvider

type SessionsProvider interface {
	New(id string, cleanStart bool) (Session, error)
	Get(id string, cleanStart bool) (Session, error)
	Del(id string)
	Save(id string) error
	Count() int
	Close() error
}

type Status

type Status uint8
const (
	NULL    Status // 从未连接过(之前 cleanStart为1 的也为NULL)
	ONLINE         // 在线
	OFFLINE        // cleanStart为0,且连接过mqtt集群,已离线,会返回offlineTime(离线时间)
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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