Skip to content

Commit

Permalink
Pass initiator and reason to connection::close
Browse files Browse the repository at this point in the history
  • Loading branch information
bmalinowsky committed Aug 18, 2024
1 parent 81e66b4 commit 575d494
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/io/calimero/knxnetip/StreamConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -212,12 +212,16 @@ private enum SessionState { Idle, Unauthenticated, Authenticated }

@Override
public void close() {
close(CloseEvent.USER_REQUEST, "user request");
}

void close(final int initiator, final String reason) {
if (sessionState == SessionState.Idle)
return;

sessionState = SessionState.Idle;
keepAliveFuture.cancel(false);
securedConnections.values().forEach(ClientConnection::close);
securedConnections.values().forEach(c -> c.close(initiator, reason, Level.DEBUG, null));
securedConnections.clear();
conn.sessions.remove(sessionId);

Expand Down Expand Up @@ -647,7 +651,7 @@ void close(final int initiator, final String reason) {
unsecuredConnections.values().forEach(t -> t.close(initiator, reason, Level.DEBUG, null));
unsecuredConnections.clear();

sessions.values().forEach(SecureSession::close);
sessions.values().forEach(s -> s.close(initiator, reason));
sessions.clear();
}

Expand Down

0 comments on commit 575d494

Please sign in to comment.