aboutsummaryrefslogtreecommitdiff
path: root/clients.go
diff options
context:
space:
mode:
authorRunxi Yu <me@runxiyu.org>2024-12-08 10:04:03 +0800
committerRunxi Yu <me@runxiyu.org>2024-12-08 10:04:03 +0800
commitda1b2cac2940eb1cf7f67328762fd5db5e1a0c8d (patch)
treec033fa01658d3768236caacb696019551e1439b1 /clients.go
parentPrimitive nick registration (diff)
downloadmeseircd-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.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/clients.go b/clients.go
index a181f99..53fd134 100644
--- a/clients.go
+++ b/clients.go
@@ -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 (