rename removing of connection IDs to retiring

This commit is contained in:
Marten Seemann
2018-11-13 14:14:05 +07:00
parent c8ae4fada0
commit a3831b2134
9 changed files with 56 additions and 56 deletions

View File

@@ -51,11 +51,11 @@ func (h *packetHandlerMap) Add(id protocol.ConnectionID, handler packetHandler)
h.mutex.Unlock()
}
func (h *packetHandlerMap) Remove(id protocol.ConnectionID) {
h.removeByConnectionIDAsString(string(id))
func (h *packetHandlerMap) Retire(id protocol.ConnectionID) {
h.retireByConnectionIDAsString(string(id))
}
func (h *packetHandlerMap) removeByConnectionIDAsString(id string) {
func (h *packetHandlerMap) retireByConnectionIDAsString(id string) {
time.AfterFunc(h.deleteClosedSessionsAfter, func() {
h.mutex.Lock()
delete(h.handlers, id)
@@ -79,7 +79,7 @@ func (h *packetHandlerMap) CloseServer() {
go func(id string, handler packetHandler) {
// session.Close() blocks until the CONNECTION_CLOSE has been sent and the run-loop has stopped
_ = handler.Close()
h.removeByConnectionIDAsString(id)
h.retireByConnectionIDAsString(id)
wg.Done()
}(id, handler)
}