Documentation ¶
Index ¶
- Constants
- Variables
- func Encode(adp ProtoAdapter, pkt Packet) (bytes.Buffer, error)
- func StreamConn(stream grpc.Stream) *plugins.Conn
- type Connack
- type Connect
- type Disconnect
- type FixedHeader
- type GrpcServer
- type Handler
- type HttpServer
- type Info
- type Options
- type Packet
- type Pingreq
- type Pingresp
- type Proto
- type ProtoAdapter
- type Puback
- type Pubcomp
- type Publish
- type Pubrec
- type Pubrel
- type Server
- type Suback
- type Subscribe
- type TcpServer
- type TopicQOSTuple
- type Unsuback
- type Unsubscribe
Constants ¶
const ( CONNECT = uint8(iota + 1) CONNACK PUBLISH PUBACK PUBREC PUBREL PUBCOMP SUBSCRIBE SUBACK UNSUBSCRIBE UNSUBACK PINGREQ PINGRESP DISCONNECT )
const (
MaxMessageSize = 1 << 19
)
Variables ¶
var ErrServerClosed = errors.New("Server closed")
ErrServerClosed occurs when a tcp server is closed.
Functions ¶
Types ¶
type Connack ¶
Connack represents an connack packet. 0x00 connection accepted 0x01 refused: unacceptable proto version 0x02 refused: identifier rejected 0x03 refused server unavailiable 0x04 bad user or password 0x05 not authorized
type Connect ¶
type Connect struct { ProtoName []byte Version uint8 InsecureFlag bool UsernameFlag bool PasswordFlag bool WillRetainFlag bool WillQOS uint8 WillFlag bool CleanSessFlag bool KeepAlive uint16 ClientID []byte WillTopic []byte WillMessage []byte Username []byte Password []byte Packet }
Connect represents a connect packet.
type Disconnect ¶
type Disconnect struct {
Packet
}
Disconnect is to signal you want to cease communications with the server
func (*Disconnect) Info ¶
func (d *Disconnect) Info() Info
Info returns Qos and MessageID of this packet.
type FixedHeader ¶
FixedHeader
type GrpcServer ¶
type GrpcServer server
func NewGrpcServer ¶
func NewGrpcServer(opts ...Options) *GrpcServer
func (*GrpcServer) Stream ¶
func (s *GrpcServer) Stream(stream pbx.Unitd_StreamServer) error
Stream implements duplex Unitd.Stream
type Handler ¶
Handler is a callback which get called when a tcp, websocket connection is established or a grpc stream is established
type HttpServer ¶
type HttpServer server
func NewHttpServer ¶
func NewHttpServer(opts ...Options) *HttpServer
func (*HttpServer) HandleFunc ¶
func (s *HttpServer) HandleFunc(w http.ResponseWriter, r *http.Request)
type Options ¶
type Options interface {
// contains filtered or unexported methods
}
Options it contains configurable options for client
func WithDefaultOptions ¶
func WithDefaultOptions() Options
WithDefaultOptions will create client connection with some default values.
KeepAlive: true TlsConfig: nil
func WithTLSConfig ¶
WithTLSConfig will set an SSL/TLS configuration to be used when connecting to server.
type Packet ¶
Packet is the interface all our packets in the line protocol will be implementing
func ReadPacket ¶
func ReadPacket(adp ProtoAdapter, r io.Reader) (Packet, error)
type Pingresp ¶
type Pingresp struct {
Packet
}
Pingresp is for saying "hey, the server is alive"
type ProtoAdapter ¶
type Puback ¶
Puback is sent for QOS level one to verify the receipt of a publish Qoth the spec: "A PUBACK Packet is sent by a server in response to a PUBLISH Packet from a publishing client, and by a subscriber in response to a PUBLISH Packet from the server."
type Pubcomp ¶
Pubcomp is for saying is in response to a pubrel sent by the publisher the final member of the QOS2 flow. both sides have said "hey, we did it!"
type Publish ¶
type Publish struct { FixedHeader Topic []byte MessageID uint16 IsForwarded bool Payload []byte Packet }
Publish represents a publish packet.
type Pubrec ¶
type Pubrec struct { FixedHeader MessageID uint16 Packet }
Pubrec is for verifying the receipt of a publish Qoth the spec:"It is the second Packet of the QoS level 2 protocol flow. A PUBREC Packet is sent by the server in response to a PUBLISH Packet from a publishing client, or by a subscriber in response to a PUBLISH Packet from the server."
type Pubrel ¶
type Pubrel struct { FixedHeader MessageID uint16 Packet }
Pubrel is a response to pubrec from either the client or server.
type Suback ¶
Suback is to say "hey, you got it buddy. I will send you messages that fit this pattern"
type Subscribe ¶
type Subscribe struct { FixedHeader MessageID uint16 IsForwarded bool Subscriptions []TopicQOSTuple Packet }
Subscribe tells the server which topics the client would like to subscribe to
type TopicQOSTuple ¶
TopicQOSTuple is a struct for pairing the Qos and topic together for the QOS' pairs in unsubscribe and subscribe
type Unsuback ¶
Unsuback is to unsubscribe as suback is to subscribe
type Unsubscribe ¶
type Unsubscribe struct { FixedHeader MessageID uint16 IsForwarded bool Subscriptions []TopicQOSTuple Packet }
Unsubscribe is the Packet to send if you don't want to subscribe to a topic anymore
func (*Unsubscribe) Info ¶
func (u *Unsubscribe) Info() Info
Info returns Qos and MessageID of this packet.