Format code
This commit is contained in:
parent
1a691389ec
commit
a4eaf5f8f7
3 changed files with 7 additions and 8 deletions
2
main.go
2
main.go
|
@ -38,7 +38,7 @@ func handleConnection(con net.Conn, sessions map[string]*session.Session) {
|
||||||
}
|
}
|
||||||
|
|
||||||
var sess *session.Session
|
var sess *session.Session
|
||||||
if(conReq.ConnectPakcet.ClientId != nil) {
|
if conReq.ConnectPakcet.ClientId != nil {
|
||||||
sess, exists := sessions[*conReq.ConnectPakcet.ClientId]
|
sess, exists := sessions[*conReq.ConnectPakcet.ClientId]
|
||||||
if exists {
|
if exists {
|
||||||
sess.ConnecionChannel <- conReq
|
sess.ConnecionChannel <- conReq
|
||||||
|
|
|
@ -64,7 +64,7 @@ func parsePublishPacket(control controlPacket) (PublishPacket, error) {
|
||||||
|
|
||||||
func (p PublishPacket) Write(w io.Writer) error {
|
func (p PublishPacket) Write(w io.Writer) error {
|
||||||
buf := bytes.NewBuffer([]byte{})
|
buf := bytes.NewBuffer([]byte{})
|
||||||
|
|
||||||
err := types.WriteUTF8String(buf, p.TopicName)
|
err := types.WriteUTF8String(buf, p.TopicName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -77,7 +77,6 @@ func (p PublishPacket) Write(w io.Writer) error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
err = properties.WriteProps(buf, p.Properties.ArrayOf())
|
err = properties.WriteProps(buf, p.Properties.ArrayOf())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -26,7 +26,7 @@ type Session struct {
|
||||||
// Nullable
|
// Nullable
|
||||||
Connection *Connection
|
Connection *Connection
|
||||||
SubscriptionChannel chan packets.PublishPacket
|
SubscriptionChannel chan packets.PublishPacket
|
||||||
ConnecionChannel chan ConnectionRequest
|
ConnecionChannel chan ConnectionRequest
|
||||||
|
|
||||||
ExpiryInterval time.Duration // TODO
|
ExpiryInterval time.Duration // TODO
|
||||||
expireTimer time.Timer // TODO
|
expireTimer time.Timer // TODO
|
||||||
|
@ -35,7 +35,7 @@ type Session struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type ConnectionRequest struct {
|
type ConnectionRequest struct {
|
||||||
Connection *Connection
|
Connection *Connection
|
||||||
ConnectPakcet packets.ConnectPacket
|
ConnectPakcet packets.ConnectPacket
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,9 +89,9 @@ func (s *Session) HandlerLoop() {
|
||||||
case c := <-s.ConnecionChannel:
|
case c := <-s.ConnecionChannel:
|
||||||
s.Connect(c)
|
s.Connect(c)
|
||||||
case subMessage := <-s.SubscriptionChannel:
|
case subMessage := <-s.SubscriptionChannel:
|
||||||
subMessage.QOSLevel = 0
|
subMessage.QOSLevel = 0
|
||||||
subMessage.Dup = false
|
subMessage.Dup = false
|
||||||
s.Connection.sendPacket(subMessage)
|
s.Connection.sendPacket(subMessage)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
c := <-s.ConnecionChannel
|
c := <-s.ConnecionChannel
|
||||||
|
|
Loading…
Reference in a new issue