Skip to content

Commit 487e2a1

Browse files
committed
add reason to logout
1 parent 417eb23 commit 487e2a1

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

acceptor.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,14 +172,15 @@ func (a *Acceptor) Stop() {
172172
}
173173
}
174174

175-
// StopSession logs out a specific session and closes its connection.
176-
func (a *Acceptor) StopSession(sessionID SessionID) error {
175+
// StopSession logs out a specific session with a reason and closes its connection.
176+
// The reason is sent to the client in the Logout message's Text (58) field.
177+
func (a *Acceptor) StopSession(sessionID SessionID, reason string) error {
177178
session, ok := lookupSession(sessionID)
178179
if !ok || session == nil {
179180
return errUnknownSession
180181
}
181182
if session.IsLoggedOn() {
182-
_ = session.initiateLogout("Session logout requested")
183+
_ = session.initiateLogout(reason)
183184
}
184185
if conn, ok := a.sessionConn.Load(sessionID); ok && conn != nil {
185186
_ = conn.(net.Conn).Close()

0 commit comments

Comments
 (0)