Documentation ¶
Index ¶
- Constants
- Variables
- func GenUniqueID() string
- func NewTLSConfig(tlsInfo TLSInfo) (*tls.Config, error)
- func ProcessMessage(msg *Message)
- type Broker
- func (b *Broker) OnlineOfflineNotification(clientID string, online bool)
- func (b *Broker) PublishMessage(packet *packets.PublishPacket)
- func (b *Broker) Start()
- func (b *Broker) StartClientListening(TLS bool)
- func (b *Broker) StartWebsocketListening()
- func (b *Broker) SubmitWork(clientID string, msg *Message)
- type Config
- type Message
- type TLSInfo
Constants ¶
View Source
const ( // PUB acl status PUB = 1 // SUB acl status SUB = 2 )
View Source
const ( // MessagePoolNum number of message per pool MessagePoolNum = 1024 // MessagePoolMessageNum number MessagePoolMessageNum = 1024 )
View Source
const ( // Connected status Connected = 1 // Disconnected status Disconnected = 2 )
View Source
const ( // AcceptMinSleep is the minimum acceptable sleep times on temporary errors. AcceptMinSleep = 100 * time.Millisecond // AcceptMaxSleep is the maximum acceptable sleep times on temporary errors AcceptMaxSleep = 10 * time.Second // DefaultRouteConnect Route solicitation intervals. DefaultRouteConnect = 5 * time.Second // DefaultTLSTimeout timeout of tls DefaultTLSTimeout = 5 * time.Second )
View Source
const ( // CONNECT 1 CONNECT = uint8(iota + 1) // CONNACK 2 CONNACK // PUBLISH 3 PUBLISH // PUBACK 4 PUBACK // PUBREC 5 PUBREC // PUBREL 6 PUBREL // PUBCOMP 7 PUBCOMP // SUBSCRIBE 8 SUBSCRIBE // SUBACK 9 SUBACK // UNSUBSCRIBE 10 UNSUBSCRIBE // UNSUBACK 11 UNSUBACK // PINGREQ 12 PINGREQ // PINGRESP 13 PINGRESP // DISCONNECT 14 DISCONNECT )
View Source
const ( // QosAtMostOnce 0 QosAtMostOnce byte = iota // QosAtLeastOnce 1 QosAtLeastOnce // QosExactlyOnce 2 QosExactlyOnce // QosFailure fail value QosFailure = 0x80 )
View Source
const (
// CLIENT is an end user.
CLIENT = 0
)
Variables ¶
View Source
var DefaultConfig = &Config{ Worker: 4096, Host: "0.0.0.0", Port: "1883", ACL: false, }
DefaultConfig create default config
View Source
var ( // DisconnectdPacket Disconnected packet DisconnectdPacket = packets.NewControlPacket(packets.Disconnect).(*packets.DisconnectPacket) )
Functions ¶
func NewTLSConfig ¶
NewTLSConfig create TLS config from TLS info
Types ¶
type Broker ¶
Broker struct of broker
func (*Broker) OnlineOfflineNotification ¶
OnlineOfflineNotification send msg
func (*Broker) PublishMessage ¶
func (b *Broker) PublishMessage(packet *packets.PublishPacket)
PublishMessage publish message
func (*Broker) StartClientListening ¶
StartClientListening start listening client Start a TCP listener & TLS TCP listener, on port specified by config
func (*Broker) StartWebsocketListening ¶
func (b *Broker) StartWebsocketListening()
StartWebsocketListening Start ws
func (*Broker) SubmitWork ¶
SubmitWork pass to broker a clientid & message
type Config ¶
type Config struct { Worker int `json:"workerNum"` Host string `json:"host"` Port string `json:"port"` TLSHost string `json:"tlsHost"` TLSPort string `json:"tlsPort"` WsPath string `json:"wsPath"` WsPort string `json:"wsPort"` WsTLS bool `json:"wsTLS"` TLSInfo TLSInfo `json:"tlsInfo"` ACL bool `json:"acl"` ACLConf string `json:"aclConf"` Debug bool `json:"-"` }
Config hold config parameters json fmt
func ConfigureConfig ¶
ConfigureConfig create config
func LoadConfig ¶
LoadConfig load from string(filename) and return a config
Source Files ¶
Click to show internal directories.
Click to hide internal directories.