Skip to content

Commit

Permalink
Added old version to ChangeProtocolVersionCallback
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianMichael committed Nov 26, 2023
1 parent 8c6babb commit ae86d92
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@
*/
public interface ChangeProtocolVersionCallback {

Event<ChangeProtocolVersionCallback> EVENT = EventFactory.createArrayBacked(ChangeProtocolVersionCallback.class, listeners -> version -> {
Event<ChangeProtocolVersionCallback> EVENT = EventFactory.createArrayBacked(ChangeProtocolVersionCallback.class, listeners -> (oldVersion, newVersion) -> {
for (ChangeProtocolVersionCallback listener : listeners) {
listener.onChangeProtocolVersion(version);
listener.onChangeProtocolVersion(oldVersion, newVersion);
}
});

void onChangeProtocolVersion(final VersionEnum protocolVersion);
void onChangeProtocolVersion(final VersionEnum oldVersion, final VersionEnum newVersion);
}
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,9 @@ public static void setTargetVersion(VersionEnum newVersion) {

final VersionEnum oldVersion = targetVersion;
targetVersion = newVersion;
if (oldVersion != newVersion) ChangeProtocolVersionCallback.EVENT.invoker().onChangeProtocolVersion(targetVersion);
if (oldVersion != newVersion) {
ChangeProtocolVersionCallback.EVENT.invoker().onChangeProtocolVersion(oldVersion, targetVersion);
}
}

/**
Expand Down

0 comments on commit ae86d92

Please sign in to comment.