Compare commits
No commits in common. "5cf02792793f64906da0e73b91d16569c865531f" and "206003080ae89de8f24973f587e128c3fed76acb" have entirely different histories.
5cf0279279
...
206003080a
3 changed files with 5 additions and 8 deletions
|
|
@ -33,7 +33,7 @@ public class DatabaseController {
|
|||
* @param callback Function called when the request is done
|
||||
*/
|
||||
public void addMessage(Message message, MessageCallback callback) {
|
||||
callback.onMessageSaved();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -7,8 +7,6 @@ import fr.insa.clavardator.ui.LoadingScreenController;
|
|||
import fr.insa.clavardator.ui.NoSelectionModel;
|
||||
import fr.insa.clavardator.users.PeerUser;
|
||||
import fr.insa.clavardator.util.ErrorCallback;
|
||||
import fr.insa.clavardator.util.Log;
|
||||
import javafx.application.Platform;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.Initializable;
|
||||
|
|
@ -66,9 +64,8 @@ public class ChatController implements Initializable {
|
|||
}
|
||||
|
||||
private void onMessageAdded(PeerUser user, Message message) {
|
||||
Log.v(this.getClass().getSimpleName(), "Message added: " + message.getText());
|
||||
messageList.getItems().add(message);
|
||||
Platform.runLater(() -> messageList.scrollTo(messageList.getItems().size() - 1));
|
||||
messageList.scrollTo(messageList.getItems().size() - 1);
|
||||
}
|
||||
|
||||
private void setState(State state) {
|
||||
|
|
|
|||
|
|
@ -118,11 +118,11 @@ public class PeerUser extends User implements Comparable<PeerUser> {
|
|||
connection.receive(
|
||||
msg -> {
|
||||
Log.v(this.getClass().getSimpleName(), "Received message from " + id);
|
||||
if (msg instanceof UserInformation) {
|
||||
if (msg.getClass().isInstance(UserInformation.class)) {
|
||||
assert ((UserInformation) msg).id == getId();
|
||||
Log.v(this.getClass().getSimpleName(), "Message username: " + ((UserInformation) msg).getUsername());
|
||||
setUsername(((UserInformation) msg).getUsername());
|
||||
} else if (msg instanceof Message) {
|
||||
} else if (msg.getClass().isInstance(Message.class)) {
|
||||
assert ((Message) msg).getRecipient().id != id;
|
||||
Log.v(this.getClass().getSimpleName(), "Message text: " + ((Message) msg).getText());
|
||||
history.addMessage((Message) msg);
|
||||
|
|
@ -130,7 +130,7 @@ public class PeerUser extends User implements Comparable<PeerUser> {
|
|||
},
|
||||
e -> {
|
||||
Log.e(this.getClass().getSimpleName(), "Error receiving message from " + id, e);
|
||||
if (e instanceof EOFException) {
|
||||
if (e.getClass().isInstance(EOFException.class)) {
|
||||
disconnect();
|
||||
} else {
|
||||
errorCallback.onError(e);
|
||||
|
|
|
|||
Loading…
Reference in a new issue