-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add initial distant chat to message window
- Loading branch information
Showing
15 changed files
with
460 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
ui/src/main/java/io/xeres/ui/client/message/BroadcastChatFrameHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/* | ||
* Copyright (c) 2019-2025 by David Gerber - https://zapek.com | ||
* | ||
* This file is part of Xeres. | ||
* | ||
* Xeres is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* Xeres is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with Xeres. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package io.xeres.ui.client.message; | ||
|
||
import io.xeres.common.message.MessageType; | ||
import jakarta.annotation.Nonnull; | ||
import javafx.application.Platform; | ||
import org.springframework.messaging.simp.stomp.StompFrameHandler; | ||
import org.springframework.messaging.simp.stomp.StompHeaders; | ||
|
||
import java.lang.reflect.Type; | ||
|
||
import static io.xeres.common.message.MessageHeaders.MESSAGE_TYPE; | ||
|
||
/** | ||
* This handles the incoming broadcast messages from the server to the UI. | ||
* XXX: not used yet | ||
*/ | ||
public class BroadcastChatFrameHandler implements StompFrameHandler | ||
{ | ||
/** | ||
* Gets the payload type. It's not possible to use null or new Object(). It has to be a class | ||
* that is serializable by jackson. | ||
* | ||
* @param headers the headers | ||
* @return a type | ||
*/ | ||
@Nonnull | ||
@Override | ||
public Type getPayloadType(StompHeaders headers) | ||
{ | ||
var messageType = MessageType.valueOf(headers.getFirst(MESSAGE_TYPE)); | ||
return switch (messageType) | ||
{ | ||
case CHAT_BROADCAST_MESSAGE -> Void.class; | ||
default -> throw new IllegalStateException("Unexpected value: " + messageType); | ||
}; | ||
} | ||
|
||
@Override | ||
public void handleFrame(StompHeaders headers, Object payload) | ||
{ | ||
var messageType = MessageType.valueOf(headers.getFirst(MESSAGE_TYPE)); | ||
Platform.runLater(() -> { | ||
switch (messageType) | ||
{ | ||
case CHAT_BROADCAST_MESSAGE -> | ||
{ /* handled as a notification */ } | ||
} | ||
} | ||
); | ||
} | ||
} |
Oops, something went wrong.