Skip to content

Commit

Permalink
chat bug fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
alishirmohammadi committed Jul 8, 2019
1 parent 1968d30 commit b4edaec
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 39 deletions.
2 changes: 1 addition & 1 deletion src/client/controllers/ChatClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class ChatClient {
public static Response sendMessage(String message) {
ServerConnection serverConnection = new ServerConnection("/chat/send_message");
serverConnection.parameters.put("token", token);
serverConnection.parameters.put("message", message);
serverConnection.parameters.put("text", message);
return serverConnection.getResponse();
}

Expand Down
36 changes: 2 additions & 34 deletions src/client/layouts/match_select.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -21,40 +21,8 @@
<VBox alignment="center" spacing="10">
<JFXTextField prefWidth="1000" text="salam" styleClass="input-text" onAction="#sendMessage" fx:id="messageField"/>
<ScrollPane prefHeight="250" styleClass="scroll-pane" style="-fx-background-color: transparent">
<VBox style="-fx-background-color: transparent;" fx:id="chats">
<HBox alignment="CENTER_RIGHT" styleClass="chat-container">
<Label styleClass="chat-message, chat-right" text="salam"/>
</HBox>
<HBox alignment="CENTER_LEFT" styleClass="chat-container">
<Label styleClass="chat-message, chat-left" text="salam"/>
</HBox>
<HBox alignment="CENTER_RIGHT" styleClass="chat-container">
<Label styleClass="chat-message, chat-right" text="salam"/>
</HBox>
<HBox alignment="CENTER_LEFT" styleClass="chat-container">
<Label styleClass="chat-message, chat-left" text="salam"/>
</HBox>
<HBox alignment="CENTER_RIGHT" styleClass="chat-container">
<Label styleClass="chat-message, chat-right" text="salam"/>
</HBox>
<HBox alignment="CENTER_LEFT" styleClass="chat-container">
<Label styleClass="chat-message, chat-left" text="salam"/>
</HBox>
<HBox alignment="CENTER_RIGHT" styleClass="chat-container">
<Label styleClass="chat-message, chat-right" text="salamsallamsalamsalamsalamsalamsalamsalamsalamsalamsalamsalamsalamsalamsalamsalamsalamsalamsalamsalamsalamsalamsalamsalamsalamsalamsalamsalamsalamsa"/>
</HBox>
<HBox alignment="CENTER_LEFT" styleClass="chat-container">
<Label styleClass="chat-message, chat-left" text="salam"/>
</HBox>
<HBox alignment="CENTER_RIGHT" styleClass="chat-container">
<Label styleClass="chat-message, chat-right" text="salam"/>
</HBox>
<HBox alignment="CENTER_LEFT" styleClass="chat-container">
<Label styleClass="chat-message, chat-left" text="salam"/>
</HBox>
<HBox alignment="CENTER_RIGHT" styleClass="chat-container">
<Label styleClass="chat-message, chat-right" text="salam"/>
</HBox>
<VBox style="-fx-background-color: transparent;" spacing="4" fx:id="chats">

</VBox>
</ScrollPane>
</VBox>
Expand Down
5 changes: 1 addition & 4 deletions src/client/views/graphics/GraphicPreBattleMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ public void backToMainMenu(MouseEvent mouseEvent) {

public void sendMessage(ActionEvent actionEvent) {
String message = messageField.getText();
messageField.setText("");
ChatClient.sendMessage(message);
Platform.runLater(this::updateMessage);
}
Expand All @@ -118,10 +119,7 @@ private void updateMessage() {
if (update != null) {
for (int i = update.messages.size() - 1; i >= 0; i--) {
chats.getChildren().add(getMessageView(update.messages.get(i)));
System.out.println(update.messages.get(i).text);
}
} else {
System.out.println("update is null");
}
}

Expand All @@ -142,7 +140,6 @@ public HBox getMessageView(Message message) {

@Override
public void initialize(URL location, ResourceBundle resources) {

ScheduledThreadPoolExecutor waitingAnimation = new ScheduledThreadPoolExecutor(1);
if (chats != null)
waitingAnimation.scheduleAtFixedRate(() -> Platform.runLater(this::updateMessage), 0, 1, TimeUnit.SECONDS);
Expand Down

0 comments on commit b4edaec

Please sign in to comment.