Fixed bug not re-performing handshake on logout

Fixes #31
This commit is contained in:
Leon Hofmeister 2020-09-25 22:00:34 +02:00
parent af219274f5
commit 108db1ae11
Signed by: delvh
GPG Key ID: 3DECE05F6D9A647C
5 changed files with 14 additions and 13 deletions

View File

@ -31,10 +31,8 @@ public class ShutdownHelper {
public static void exit() {
if (Settings.getInstance().isHideOnClose()) Context.getInstance().getStage().setIconified(true);
else {
final var alert = new Alert(AlertType.CONFIRMATION);
alert.setTitle("Exit?");
alert.setContentText("Are you sure you want to exit Envoy?");
AlertHelper.confirmAction(alert, () -> { EventBus.getInstance().dispatch(new EnvoyCloseEvent()); System.exit(0); });
EventBus.getInstance().dispatch(new EnvoyCloseEvent());
System.exit(0);
}
}

View File

@ -240,8 +240,11 @@ public final class Client implements EventListener, Closeable {
if (online) {
logger.log(Level.INFO, "Closing connection...");
try {
socket.close();
// The sender must be reset as otherwise the handshake is immediately closed
sender = null;
online = false;
socket.close();
} catch (final IOException e) {
logger.log(Level.WARNING, "Failed to close socket: ", e);
}

View File

@ -111,8 +111,9 @@ public final class SceneContext implements EventListener {
// Add the option to exit Linux-like with "Control" + "Q"
scene.getAccelerators().put(new KeyCodeCombination(KeyCode.Q, KeyCombination.CONTROL_DOWN), ShutdownHelper::exit);
// Add the option to logout using "Control"+"Shift"+"L"
scene.getAccelerators()
// Add the option to logout using "Control"+"Shift"+"L" if not in login scene
if (sceneInfo != SceneInfo.LOGIN_SCENE) scene.getAccelerators()
.put(new KeyCodeCombination(KeyCode.L, KeyCombination.CONTROL_DOWN, KeyCombination.SHIFT_DOWN), ShutdownHelper::logout);
// Add the option to open the settings scene with "Control"+"S", if being in

View File

@ -117,7 +117,6 @@ public final class Startup extends Application {
cacheMap.put(MessageStatusChange.class, new Cache<MessageStatusChange>());
cacheMap.put(GroupMessageStatusChange.class, new Cache<GroupMessageStatusChange>());
try {
final var client = context.getClient();
client.performHandshake(credentials, cacheMap);
if (client.isOnline()) {
loadChatScene();
@ -211,7 +210,7 @@ public final class Startup extends Application {
if (StatusTrayIcon.isSupported()) {
// Configure hide on close
// Exit or minimize the stage when a close request occurs
stage.setOnCloseRequest(e -> { ShutdownHelper.exit(); if (Settings.getInstance().isHideOnClose()) e.consume(); });
// Initialize status tray icon

View File

@ -72,7 +72,7 @@ public class ContactSearchTab implements EventListener {
}
/**
* Disables the clear and search button if no text is present in the search bar.
* If text is present, sends a request to the server.
*
* @since Envoy Client v0.1-beta
*/