Skip to content

Commit

Permalink
comment on newHardResetPacket
Browse files Browse the repository at this point in the history
  • Loading branch information
ainghazal committed Jan 29, 2024
1 parent 2c6c941 commit b512ad9
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions internal/session/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,26 @@ func (m *Manager) NewPacket(opcode model.Opcode, payload []byte) (*model.Packet,
return packet, nil
}

// NewHardResetPacket creates a new hard reset packet for this session.
// This packet is a special case because, if we resend, we must not bump
// its packet ID. Normally retransmission is handled at the reliabletransport layer,
// but we send hard resets at the muxer.
func (m *Manager) NewHardResetPacket(first bool) (*model.Packet, error) {
packet := model.NewPacket(
model.P_CONTROL_HARD_RESET_CLIENT_V2,
m.keyID,
[]byte{},
)
if first {
pid, _ := m.localControlPacketIDLocked()
packet.ID = pid
} else {
packet.ID = 0
}
copy(packet.LocalSessionID[:], m.localSessionID[:])
return packet, nil
}

var ErrExpiredKey = errors.New("expired key")

// LocalDataPacketID returns an unique Packet ID for the Data Channel. It
Expand Down

0 comments on commit b512ad9

Please sign in to comment.