From c9cdc50dedb0bd829a47916ae4d08b61109033a6 Mon Sep 17 00:00:00 2001 From: Jim Date: Fri, 18 Oct 2024 18:32:18 -0400 Subject: [PATCH] fix (examples): add gldap.OnClose func to example --- examples/simple/main.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/examples/simple/main.go b/examples/simple/main.go index 172b980..826298a 100644 --- a/examples/simple/main.go +++ b/examples/simple/main.go @@ -24,8 +24,14 @@ func main() { // a very simple way to track authenticated connections authenticatedConnections := map[int]struct{}{} + // a gldap.OnClose function to clean up connections from the + // authenticatedConnections map when they are closed + onCloseFn := func(connId int) { + delete(authenticatedConnections, connId) + log.Printf("connection %d closed", connId) + } // create a new server - s, err := gldap.NewServer(gldap.WithLogger(l), gldap.WithDisablePanicRecovery()) + s, err := gldap.NewServer(gldap.WithLogger(l), gldap.WithDisablePanicRecovery(), gldap.WithOnClose(onCloseFn)) if err != nil { log.Fatalf("unable to create server: %s", err.Error()) }