common

package
v0.0.0-...-e5a160e Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2018 License: MIT Imports: 10 Imported by: 2

Documentation

Overview

Copyright 2014, Shuhei Tanuma. All rights reserved. Use of this source code is governed by a MIT license that can be found in the LICENSE file.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Connection

type Connection interface {
	//WriteMessage(request mqtt.Message) error
	WriteMessageQueue(request mqtt.Message)

	Close() error

	SetState(State)

	GetState() State

	ResetState()

	ReadMessage() (mqtt.Message, error)

	IsAlived() bool

	SetWillMessage(mqtt.WillMessage)

	GetWillMessage() *mqtt.WillMessage

	HasWillMessage() bool

	GetOutGoingTable() *util.MessageTable

	GetSubscribedTopics() map[string]*SubscribeSet

	AppendSubscribedTopic(string, *SubscribeSet)

	RemoveSubscribedTopic(string)

	SetKeepaliveInterval(int)

	GetId() string

	GetRealId() string

	SetId(string)

	DisableCleanSession()

	ShouldCleanSession() bool

	IsBridge() bool
}

TODO: あんまり実情にあってないのでみなおそう

type ConnectionError

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

func (*ConnectionError) Error

func (e *ConnectionError) Error() string

type ConnectionResetError

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

func (*ConnectionResetError) Error

func (e *ConnectionResetError) Error() string

type MyConfig

type MyConfig struct {
	QueueSize        int
	MaxMessageSize   int
	OfflineQueueSize int
	Keepalive        int
	WritePerSec      int
	Logger           log.Logger
}

func GetDefaultMyConfig

func GetDefaultMyConfig() *MyConfig

type MyConnection

type MyConnection struct {
	MyConnection     io.ReadWriteCloser
	Events           map[string]interface{}
	Queue            chan codec.Message
	OfflineQueue     []codec.Message
	MaxOfflineQueue  int
	InflightTable    *util.MessageTable
	SubscribeHistory map[string]int
	PingCounter      int
	Reconnect        bool
	Mutex            sync.RWMutex
	Kicker           *time.Timer
	Keepalive        int
	Id               string
	Qlobber          *util.Qlobber
	WillMessage      *codec.WillMessage
	SubscribedTopics map[string]int
	Opaque           interface{}
	Last             time.Time
	State            State
	CleanSession     bool
	Connected        bool
	Closed           chan bool
	Reader           *bufio.Reader
	Writer           *bufio.Writer
	KeepLoop         bool

	MaxMessageSize int

	Bridged bool
	// contains filtered or unexported fields
}

func NewMyConnection

func NewMyConnection(conf *MyConfig) *MyConnection

TODO: どっかで綺麗にしたい

func (*MyConnection) AppendSubscribedTopic

func (self *MyConnection) AppendSubscribedTopic(topic string, set *SubscribeSet)

func (*MyConnection) Close

func (self *MyConnection) Close() error

func (*MyConnection) DisableCleanSession

func (self *MyConnection) DisableCleanSession()

func (*MyConnection) Disconnect

func (self *MyConnection) Disconnect()

func (*MyConnection) GetId

func (self *MyConnection) GetId() string

func (*MyConnection) GetOpaque

func (self *MyConnection) GetOpaque() interface{}

func (*MyConnection) GetOutGoingTable

func (self *MyConnection) GetOutGoingTable() *util.MessageTable

func (*MyConnection) GetRealId

func (self *MyConnection) GetRealId() string

func (*MyConnection) GetState

func (self *MyConnection) GetState() State

func (*MyConnection) GetSubscribedTopics

func (self *MyConnection) GetSubscribedTopics() map[string]*SubscribeSet

func (*MyConnection) GetWillMessage

func (self *MyConnection) GetWillMessage() *codec.WillMessage

func (*MyConnection) HasMyConnection

func (self *MyConnection) HasMyConnection() bool

func (*MyConnection) HasWillMessage

func (self *MyConnection) HasWillMessage() bool

func (*MyConnection) IsAlived

func (self *MyConnection) IsAlived() bool

func (*MyConnection) IsBridge

func (self *MyConnection) IsBridge() bool

func (*MyConnection) On

func (self *MyConnection) On(event string, callback interface{}, args ...bool) error

func (*MyConnection) ParseMessage

func (self *MyConnection) ParseMessage() (codec.Message, error)

func (*MyConnection) Ping

func (self *MyConnection) Ping()

func (*MyConnection) Publish

func (self *MyConnection) Publish(TopicName string, Payload []byte, QosLevel int, retain bool, opaque interface{})

func (*MyConnection) Read

func (self *MyConnection) Read(p []byte) (int, error)

func (*MyConnection) ReadMessage

func (self *MyConnection) ReadMessage() (codec.Message, error)

func (*MyConnection) RemoveSubscribedTopic

func (self *MyConnection) RemoveSubscribedTopic(topic string)

func (*MyConnection) ResetState

func (self *MyConnection) ResetState()

func (*MyConnection) SetId

func (self *MyConnection) SetId(id string)

func (*MyConnection) SetKeepaliveInterval

func (self *MyConnection) SetKeepaliveInterval(interval int)

func (*MyConnection) SetMyConnection

func (self *MyConnection) SetMyConnection(c io.ReadWriteCloser)

func (*MyConnection) SetOpaque

func (self *MyConnection) SetOpaque(opaque interface{})

func (*MyConnection) SetRequestPerSecondLimit

func (self *MyConnection) SetRequestPerSecondLimit(limit int)

func (*MyConnection) SetState

func (self *MyConnection) SetState(state State)

func (*MyConnection) SetWillMessage

func (self *MyConnection) SetWillMessage(will codec.WillMessage)

func (*MyConnection) ShouldCleanSession

func (self *MyConnection) ShouldCleanSession() bool

func (*MyConnection) Subscribe

func (self *MyConnection) Subscribe(topic string, QoS int) error

func (*MyConnection) Terminate

func (self *MyConnection) Terminate()

func (*MyConnection) Unsubscribe

func (self *MyConnection) Unsubscribe(topic string)

func (*MyConnection) Write

func (self *MyConnection) Write(b []byte) (int, error)

func (*MyConnection) WriteMessageQueue

func (self *MyConnection) WriteMessageQueue(request codec.Message)

type State

type State int32
const (
	STATE_INIT State = iota
	STATE_CONNECTING
	STATE_CONNECTED
	STATE_ACCEPTED
	STATE_IDLE
	STATE_DETACHED
	STATE_SEND
	STATE_RECEIVE
	STATE_SHUTDOWN
	STATE_CLOSED
)

ConnectionState: Idle, Send, Receive and Handshake?

type SubscribeSet

type SubscribeSet struct {
	ClientId    string `json:"client_id"`
	TopicFilter string `json:"topic_filter"`
	QoS         int    `json:"qos"`
}

func (*SubscribeSet) String

func (self *SubscribeSet) String() string

Jump to

Keyboard shortcuts

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