Files
next.orly.dev/app/handle-close.go
mleku 110223fc4e Migrate internal module imports to unified package path.
Replaced legacy `*.orly` module imports with `next.orly.dev/pkg` paths across the codebase for consistency. Removed legacy `go.mod` files from sub-packages, consolidating dependency management. Added Dockerfiles and configurations for benchmarking environments.
2025-09-12 16:12:31 +01:00

36 lines
756 B
Go

package app
import (
"errors"
"lol.mleku.dev/chk"
"lol.mleku.dev/log"
"next.orly.dev/pkg/encoders/envelopes/closeenvelope"
)
// HandleClose processes a CLOSE envelope by unmarshalling the request,
// validates the presence of an <id> field, and signals cancellation for
// the associated listener through the server's publisher mechanism.
func (l *Listener) HandleClose(req []byte) (err error) {
var rem []byte
env := closeenvelope.New()
if rem, err = env.Unmarshal(req); chk.E(err) {
return
}
if len(rem) > 0 {
log.I.F("extra '%s'", rem)
}
if len(env.ID) == 0 {
return errors.New("CLOSE has no <id>")
}
l.publishers.Receive(
&W{
Cancel: true,
remote: l.remote,
Conn: l.conn,
Id: string(env.ID),
},
)
return
}