Fix client id assignment

This commit is contained in:
bad 2021-10-16 22:44:14 +02:00
parent 7cab972065
commit 9226c0abda

View file

@ -55,11 +55,15 @@ func (s *Session) Connect(req ConnectionRequest) {
s.updateExpireTimer(req.ConnectPakcet.Properties.SessionExpiryInterval.Value) s.updateExpireTimer(req.ConnectPakcet.Properties.SessionExpiryInterval.Value)
if req.ConnectPakcet.ClientId != nil { if req.ConnectPakcet.ClientId == nil {
if s.ClientID == nil { if s.ClientID == nil {
s.ClientID = genClientID() s.ClientID = genClientID()
} }
connAck.Properties.AssignedClientIdentifier.Value = s.ClientID connAck.Properties.AssignedClientIdentifier.Value = s.ClientID
} else if s.ClientID != nil && s.ClientID != req.ConnectPakcet.ClientId {
panic(fmt.Errorf("Session %s connect called with a connect packet with an ID: %s", *s.ClientID, *req.ConnectPakcet.ClientId))
} else {
s.ClientID = req.ConnectPakcet.ClientId
} }
true := byte(1) true := byte(1)