aboutsummaryrefslogtreecommitdiff
path: root/clients.go
diff options
context:
space:
mode:
authorRunxi Yu <me@runxiyu.org>2024-12-08 10:32:29 +0800
committerRunxi Yu <me@runxiyu.org>2024-12-08 10:32:29 +0800
commit6bbe00f0c7aae6c468b1a3e12983a74a170e92b8 (patch)
tree970b43288cdbb8c05cf5df2aaaf79e94019d13af /clients.go
parentRemove another unnecessary anonymous function (diff)
downloadmeseircd-6bbe00f0c7aae6c468b1a3e12983a74a170e92b8.tar.gz
meseircd-6bbe00f0c7aae6c468b1a3e12983a74a170e92b8.tar.zst
meseircd-6bbe00f0c7aae6c468b1a3e12983a74a170e92b8.zip
Handle send failures
Diffstat (limited to 'clients.go')
-rw-r--r--clients.go10
1 files changed, 5 insertions, 5 deletions
diff --git a/clients.go b/clients.go
index 0588184..07dc532 100644
--- a/clients.go
+++ b/clients.go
@@ -23,8 +23,6 @@ func (client *Client) Send(msg SMsg) error {
return client.SendRaw(msg.ClientSerialize())
}
-// Send failures are not returned; broken connections detected and severed on
-// the next receive.
func (client *Client) SendRaw(s string) error {
if client.conn == nil {
panic("not implemented")
@@ -35,6 +33,7 @@ func (client *Client) SendRaw(s string) error {
// TODO: Should shut down the netFd instead but the stdlib
// doesn't expose a way to do this.
(*client.conn).Close()
+ return err
}
return nil
}
@@ -86,14 +85,15 @@ func NewLocalClient(conn *net.Conn) (*Client, error) {
return nil, ErrUIDBusy
}
-func (client *Client) checkRegistration() {
+func (client *Client) checkRegistration() error {
if client.State != ClientStatePreRegistration {
slog.Error("spurious call to checkRegistration", "client", client)
- return // TODO: Return an error?
+ return ErrCallState
}
if client.Nick != "*" && client.Ident != "" {
- client.Send(MakeMsg(self, RPL_WELCOME, client.Nick, "Welcome"))
+ return client.Send(MakeMsg(self, RPL_WELCOME, client.Nick, "Welcome"))
}
+ return nil
}
type ClientState uint8