diff options
author | Runxi Yu <me@runxiyu.org> | 2024-12-08 10:04:03 +0800 |
---|---|---|
committer | Runxi Yu <me@runxiyu.org> | 2024-12-08 10:04:03 +0800 |
commit | da1b2cac2940eb1cf7f67328762fd5db5e1a0c8d (patch) | |
tree | c033fa01658d3768236caacb696019551e1439b1 /clients.go | |
parent | Primitive nick registration (diff) | |
download | meseircd-da1b2cac2940eb1cf7f67328762fd5db5e1a0c8d.tar.gz meseircd-da1b2cac2940eb1cf7f67328762fd5db5e1a0c8d.tar.zst meseircd-da1b2cac2940eb1cf7f67328762fd5db5e1a0c8d.zip |
Client teardown and proper nick changes
Diffstat (limited to 'clients.go')
-rw-r--r-- | clients.go | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -45,6 +45,18 @@ func (client Client) ServerSource() string { return client.UID } +func (client *Client) Teardown() { + if client.conn != nil { + (*client.conn).Close() + } + if !uidToClient.CompareAndDelete(client.UID, client) { + slog.Error("uid inconsistent", "uid", client.UID, "client", client) + } + if !nickToClient.CompareAndDelete(client.Nick, client) { + slog.Error("nick inconsistent", "nick", client.Nick, "client", client) + } +} + type ClientState uint8 const ( |