session

package
v0.0.0-...-2aa8555 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2021 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrTopicsCount the count of topic is zero
	ErrTopicsCount = errors.New("the count of topic is zero")
	// ErrTopicsQoSsCount the count of topic and qoss
	ErrTopicsQoSsCount = errors.New("the count of topics and the count of qoss is not equal")
	// ErrQoSInvalid qos is invalid
	ErrQoSInvalid = errors.New("qos is invalid")
	// ErrPacketInvalid packet is invalid"
	ErrPacketInvalid = errors.New("packet is invalid")
)
View Source
var (
	// ErrClosed The client side is normally closed
	ErrClosed = errors.New("recv a the disconnected packet")
)

Functions

func NewACK

func NewACK() *ack

NewACK create a new object

func NewProcessor

func NewProcessor(ctx *context.SessionContext, notifyHandler NotifyHandler) *processor

NewProcessor create a new object

func NewSyncList

func NewSyncList() *syncList

NewSyncList returns an initialized list.

Types

type Conn

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

Conn is used for write/read operations on MQTT packages

func NewConn

func NewConn(ctx *context.SessionContext) *Conn

NewConn create a new object

func (*Conn) Close

func (c *Conn) Close()

func (*Conn) Timer

func (c *Conn) Timer(handler func() error)

Timer the client reads and writes timeout

type NotifyHandler

type NotifyHandler func(topic string, last []byte)

NotifyHandler register recv pushcli notice

type Session

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

Session link painting information

func NewSession

func NewSession(ctx *context.MqttSrvContext, c *poll.Conn) *Session

NewSession create a new session object

func (*Session) Close

func (s *Session) Close() error

Close close session and clean information

func (*Session) CompareAndSwapProcessState

func (s *Session) CompareAndSwapProcessState(olds, news context.WorkState) bool

func (*Session) CompareAndSwapReadState

func (s *Session) CompareAndSwapReadState(olds, news context.WorkState) bool

func (*Session) CompareAndSwapWriteState

func (s *Session) CompareAndSwapWriteState(olds, news context.WorkState) bool

func (*Session) CompareProcessState

func (s *Session) CompareProcessState(expect context.WorkState) bool

func (*Session) CompareReadState

func (s *Session) CompareReadState(expect context.WorkState) bool

func (*Session) CompareState

func (s *Session) CompareState(expect context.SessionState) bool

func (*Session) CompareWriteState

func (s *Session) CompareWriteState(expect context.WorkState) bool

func (*Session) IsWrite

func (s *Session) IsWrite(noWriteHandler func(), writeHandler func()) bool

IsWrite When the write buffer is not empty return true otherwise return false

func (*Session) KickClose

func (s *Session) KickClose(cid int64) bool

KickClose used to kick off the connection operation maybe a bug The second shutdown failed because of the once operation, and the first shutdown was incomplete If the store USES transactional operations, there is no bug

func (*Session) Notify

func (s *Session) Notify(topic string, last []byte)

Notify receive a notification that if the latest location is greater than or equal to the lastest of the record, the post triggers a pull message operation

func (*Session) PutReadBuffer

func (s *Session) PutReadBuffer(pkg packets.ControlPacket) error

PutReadBuffer put pkg the packet of buffer if there is no the handle of function . create one

func (*Session) Read

func (s *Session) Read() error

Read an MQTT package and call back the handle function to handle it Close the connection if something goes wrong

func (*Session) State

func (s *Session) State() context.SessionState

func (*Session) StoreProcessState

func (s *Session) StoreProcessState(state context.WorkState)

func (*Session) StoreReadState

func (s *Session) StoreReadState(state context.WorkState)

func (*Session) StoreWriteState

func (s *Session) StoreWriteState(state context.WorkState)

func (*Session) Write

func (s *Session) Write() error

Write an MQTT packet to the client biz must ensure the correct order of writechan

Jump to

Keyboard shortcuts

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