Adding some more traces and donginsome small fixes

This commit is contained in:
dcollin 2015-10-28 12:58:33 +01:00
parent 35af69def3
commit 94c8b0dd72
5 changed files with 58 additions and 40 deletions

View file

@ -125,6 +125,7 @@ public class CoderClient extends Application{
this.selectServerDialog.addSelectProjectDialogListener(new SelectServerDialogListener() { this.selectServerDialog.addSelectProjectDialogListener(new SelectServerDialogListener() {
@Override @Override
public void willShow() { public void willShow() {
logger.fine("about to show select server dialog on main stage");
closeCurrentSession(); closeCurrentSession();
selectServerDialog.clearServerList(); selectServerDialog.clearServerList();
if(ssdpClient != null){ if(ssdpClient != null){
@ -162,7 +163,7 @@ public class CoderClient extends Application{
this.loginDialog.addLoginDialogListener(new LoginDialogListener(){ this.loginDialog.addLoginDialogListener(new LoginDialogListener(){
@Override @Override
public void willShow() { public void willShow() {
logger.fine("about to show login dialog on main stage");
} }
@Override @Override
public void cancel() { public void cancel() {
@ -179,30 +180,7 @@ public class CoderClient extends Application{
loginDialog.setErrorMessage("Wrong username or password"); loginDialog.setErrorMessage("Wrong username or password");
selectServerDialog.showOnStage(mainStage); selectServerDialog.showOnStage(mainStage);
return; return;
}else{ }else{
// create a guard for when the session is closed
new Thread(new Runnable(){
@Override
public void run() {
logger.fine("starting a session guard");
while(true){
if(session == null || !session.isConnected()){
logger.fine("session guard: no connection");
Platform.runLater(new Runnable() {
@Override
public void run() {
selectServerDialog.setErrorMessage("The current session was disconnected");
closeCurrentSession();
selectServerDialog.showOnStage(mainStage);
}
});
break;
}
Thread.yield();
}
logger.fine("terminating session guard");
}}).start();
loginDialog.setErrorMessage(""); loginDialog.setErrorMessage("");
setupSessionListener(); //resister a message listener to the session setupSessionListener(); //resister a message listener to the session
session.start(); //start receiving traffic from the server session.start(); //start receiving traffic from the server
@ -224,6 +202,28 @@ public class CoderClient extends Application{
logger.warning("Cannot setup session listeners for a non-authenticated session. ignoring call."); logger.warning("Cannot setup session listeners for a non-authenticated session. ignoring call.");
return; return;
} }
// create a guard for when the session is closed
new Thread(new Runnable(){
@Override
public void run() {
logger.fine("starting a session guard");
while(true){
if(session == null || !session.isConnected()){
logger.fine("session guard: no connection");
Platform.runLater(new Runnable() {
@Override
public void run() {
selectServerDialog.setErrorMessage("The current session was disconnected");
closeCurrentSession();
selectServerDialog.showOnStage(mainStage);
}
});
break;
}
Thread.yield();
}
logger.fine("terminating session guard");
}}).start();
session.addCoderMessageReceivedListener(new CoderMessageReceivedListener() { session.addCoderMessageReceivedListener(new CoderMessageReceivedListener() {
@Override @Override
public void projectListRspReceived(final Map<String, ProjectListData> projectListRsp) { public void projectListRspReceived(final Map<String, ProjectListData> projectListRsp) {
@ -291,6 +291,7 @@ public class CoderClient extends Application{
this.selectProjectDialog.addSelectProjectDialogListener(new SelectProjectDialogListener() { this.selectProjectDialog.addSelectProjectDialogListener(new SelectProjectDialogListener() {
@Override @Override
public void willShow() { public void willShow() {
logger.fine("about to show select project dialog on main stage");
selectProjectDialog.clearProjectList(); selectProjectDialog.clearProjectList();
if(!selectProjectDialog.isProjectSelected()){ if(!selectProjectDialog.isProjectSelected()){
sendProjectListReq(); sendProjectListReq();
@ -335,6 +336,7 @@ public class CoderClient extends Application{
this.newProjectDialog.addNewProjectDialogListener(new NewProjectDialogListener(){ this.newProjectDialog.addNewProjectDialogListener(new NewProjectDialogListener(){
@Override @Override
public void willShow() { public void willShow() {
logger.fine("about to show new project dialog on main stage");
newProjectDialog.clearProjectTypeList(); newProjectDialog.clearProjectTypeList();
sendProjectTypeReqMsg(); sendProjectTypeReqMsg();
} }
@ -380,6 +382,7 @@ public class CoderClient extends Application{
this.editorWindow.addEditorWindowListener(new EditorWindowListener() { this.editorWindow.addEditorWindowListener(new EditorWindowListener() {
@Override @Override
public void willShow() { public void willShow() {
logger.fine("about to show edit window on main stage");
sendProjectReqMsg(); sendProjectReqMsg();
} }
@Override @Override

View file

@ -72,11 +72,11 @@ public class Session extends Thread {
try { try {
msg = in.readGenericObject(); msg = in.readGenericObject();
} catch (IOException e) { } catch (IOException e) {
logger.log(Level.FINE, "socket was probably closed by the peer", e); logger.fine("socket has been closed");
break; break;
} }
if(msg == null){ if(msg == null){
logger.fine("socket was probably closed by the peer"); logger.severe("reading null from socket. socket assumed to be closed.");
break; break;
}else{ }else{
handleMessage(msg); handleMessage(msg);
@ -182,8 +182,7 @@ public class Session extends Thread {
CoderMessage authRsp = new CoderMessage(); CoderMessage authRsp = new CoderMessage();
authRsp.AuthenticationRsp = new AuthenticationRspMsg(); authRsp.AuthenticationRsp = new AuthenticationRspMsg();
authRsp.AuthenticationRsp.timestamp = System.currentTimeMillis(); authRsp.AuthenticationRsp.timestamp = System.currentTimeMillis();
authRsp.AuthenticationRsp.hash = Hasher.PBKDF2( authRsp.AuthenticationRsp.hash = key;
hashedPassword, msg.AuthenticationChallenge.salt, AUTH_HASH_ITERATIONS);
logger.fine("Sending AuthenticationRsp"); logger.fine("Sending AuthenticationRsp");
send(authRsp); send(authRsp);

View file

@ -7,15 +7,14 @@
<?import java.lang.*?> <?import java.lang.*?>
<?import javafx.scene.control.*?> <?import javafx.scene.control.*?>
<AnchorPane prefHeight="116.0" prefWidth="378.0" xmlns="http://javafx.com/javafx/8.0.40" xmlns:fx="http://javafx.com/fxml/1"> <AnchorPane prefHeight="116.0" prefWidth="378.0" xmlns="http://javafx.com/javafx/8.0.40" xmlns:fx="http://javafx.com/fxml/1">
<children> <children>
<Label layoutX="10.0" layoutY="17.0" text="username" AnchorPane.leftAnchor="10.0" AnchorPane.topAnchor="17.0" /> <Label layoutX="10.0" layoutY="17.0" text="username" AnchorPane.leftAnchor="10.0" AnchorPane.topAnchor="17.0" />
<TextField fx:id="usernameTextField" layoutX="80.0" layoutY="13.0" onKeyPressed="#keyPressed" prefHeight="25.0" prefWidth="291.0" AnchorPane.leftAnchor="80.0" AnchorPane.rightAnchor="7.0" AnchorPane.topAnchor="13.0" /> <TextField fx:id="usernameTextField" layoutX="80.0" layoutY="13.0" onKeyPressed="#keyPressed" prefHeight="25.0" prefWidth="291.0" promptText="Username" AnchorPane.leftAnchor="80.0" AnchorPane.rightAnchor="7.0" AnchorPane.topAnchor="13.0" />
<Label layoutX="10.0" layoutY="48.0" text="password" AnchorPane.leftAnchor="10.0" AnchorPane.topAnchor="48.0" /> <Label layoutX="10.0" layoutY="48.0" text="password" AnchorPane.leftAnchor="10.0" AnchorPane.topAnchor="48.0" />
<PasswordField fx:id="passwordPasswordField" layoutX="80.0" layoutY="44.0" onKeyPressed="#keyPressed" prefHeight="25.0" prefWidth="291.0" AnchorPane.leftAnchor="80.0" AnchorPane.rightAnchor="7.0" AnchorPane.topAnchor="44.0" /> <PasswordField fx:id="passwordPasswordField" layoutX="80.0" layoutY="44.0" onKeyPressed="#keyPressed" prefHeight="25.0" prefWidth="291.0" promptText="Password" AnchorPane.leftAnchor="80.0" AnchorPane.rightAnchor="7.0" AnchorPane.topAnchor="44.0" />
<Label fx:id="errorLabel" alignment="TOP_LEFT" layoutX="10.0" layoutY="75.0" maxWidth="1.7976931348623157E308" prefHeight="35.0" prefWidth="242.0" text="error" textFill="RED" wrapText="true" /> <Label fx:id="errorLabel" alignment="TOP_LEFT" layoutX="10.0" layoutY="75.0" maxWidth="1.7976931348623157E308" prefHeight="34.0" prefWidth="216.0" text="Error Message" textFill="RED" wrapText="true" AnchorPane.bottomAnchor="7.0" AnchorPane.leftAnchor="10.0" AnchorPane.rightAnchor="152.0" AnchorPane.topAnchor="75.0" />
<HBox alignment="CENTER_RIGHT" layoutX="42.0" layoutY="34.0" prefHeight="35.0" prefWidth="200.0" AnchorPane.bottomAnchor="5.0" AnchorPane.rightAnchor="0.0"> <HBox alignment="CENTER_RIGHT" layoutX="42.0" layoutY="34.0" prefHeight="35.0" prefWidth="148.0" AnchorPane.bottomAnchor="5.0" AnchorPane.rightAnchor="0.0">
<children> <children>
<Button fx:id="cancelButton" mnemonicParsing="false" onAction="#cancel" text="Cancel"> <Button fx:id="cancelButton" mnemonicParsing="false" onAction="#cancel" text="Cancel">
<HBox.margin> <HBox.margin>

View file

@ -1,15 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.*?>
<?import javafx.scene.control.*?> <?import javafx.scene.control.*?>
<?import java.lang.*?> <?import java.lang.*?>
<?import javafx.scene.layout.*?> <?import javafx.scene.layout.*?>
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="159.0" prefWidth="382.0" xmlns="http://javafx.com/javafx/8.0.40" xmlns:fx="http://javafx.com/fxml/1"> <AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="112.0" prefWidth="382.0" xmlns="http://javafx.com/javafx/8.0.40" xmlns:fx="http://javafx.com/fxml/1">
<children> <children>
<Button fx:id="cancelButton" layoutX="60.0" layoutY="67.0" mnemonicParsing="false" onAction="#cancel" text="cancel" /> <ComboBox fx:id="projectTypeComboBox" layoutX="58.0" layoutY="39.0" prefHeight="25.0" prefWidth="196.0" promptText="Select a Project Type" AnchorPane.leftAnchor="55.0" AnchorPane.rightAnchor="10.0" />
<Button fx:id="createButton" defaultButton="true" disable="true" layoutX="195.0" layoutY="67.0" mnemonicParsing="false" onAction="#create" text="create" /> <Label fx:id="errorMessageLabel" alignment="TOP_LEFT" layoutX="14.0" layoutY="71.0" prefHeight="17.0" prefWidth="237.0" text="Error Message" textFill="RED" AnchorPane.bottomAnchor="10.0" AnchorPane.leftAnchor="10.0" AnchorPane.rightAnchor="135.0" AnchorPane.topAnchor="71.0" />
<ComboBox fx:id="projectTypeComboBox" layoutX="160.0" layoutY="21.0" prefHeight="25.0" prefWidth="196.0" promptText="Select a Project Type" /> <TextField fx:id="projectNameTextField" layoutX="58.0" layoutY="10.0" onKeyPressed="#keyPressed" prefHeight="25.0" prefWidth="314.0" promptText="Project Name" AnchorPane.leftAnchor="55.0" AnchorPane.rightAnchor="10.0" />
<Label fx:id="errorMessageLabel" layoutX="71.0" layoutY="111.0" text="Error Message" textFill="RED" /> <Label layoutX="14.0" layoutY="14.0" text="Name" AnchorPane.leftAnchor="10.0" AnchorPane.topAnchor="14.0" />
<TextField fx:id="projectNameTextField" layoutX="11.0" layoutY="21.0" onKeyPressed="#keyPressed" promptText="Project Name" /> <Label layoutX="14.0" layoutY="43.0" text="Type" AnchorPane.leftAnchor="10.0" AnchorPane.topAnchor="43.0" />
<HBox alignment="CENTER_RIGHT" layoutX="168.0" layoutY="109.0" prefHeight="35.0" prefWidth="127.0" AnchorPane.bottomAnchor="5.0" AnchorPane.rightAnchor="10.0">
<children>
<Button fx:id="cancelButton" mnemonicParsing="false" onAction="#cancel" text="cancel">
<HBox.margin>
<Insets left="10.0" />
</HBox.margin>
</Button>
<Button fx:id="createButton" defaultButton="true" disable="true" mnemonicParsing="false" onAction="#create" text="create">
<HBox.margin>
<Insets left="10.0" />
</HBox.margin>
</Button>
</children>
</HBox>
</children> </children>
</AnchorPane> </AnchorPane>

View file

@ -113,6 +113,7 @@ public class SelectProjectDialog extends GuiWindow {
@FXML @FXML
protected void newProject(ActionEvent event){ protected void newProject(ActionEvent event){
logger.fine("user triggered the new project button");
for(SelectProjectDialogListener listener : this.listeners){ for(SelectProjectDialogListener listener : this.listeners){
listener.newProject(); listener.newProject();
} }
@ -120,6 +121,7 @@ public class SelectProjectDialog extends GuiWindow {
@FXML @FXML
protected void cancel(ActionEvent event){ protected void cancel(ActionEvent event){
logger.fine("user triggered the cancel button");
for(SelectProjectDialogListener listener : this.listeners){ for(SelectProjectDialogListener listener : this.listeners){
listener.cancel(); listener.cancel();
} }