mirror of
https://github.com/2OOP/pism.git
synced 2026-02-04 10:54:51 +00:00
Working subscription, button only subs to reversi right now
This commit is contained in:
@@ -118,7 +118,7 @@ public final class Server {
|
||||
return;
|
||||
}
|
||||
|
||||
primary = new ServerView(user, this::sendChallenge);
|
||||
primary = new ServerView(user, this::sendChallenge, clientId);
|
||||
WidgetContainer.getCurrentView().transitionNextCustom(primary, "disconnect", this::disconnect);
|
||||
|
||||
a.unsubscribe("connecting");
|
||||
|
||||
@@ -10,16 +10,20 @@ import javafx.application.Platform;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.ListView;
|
||||
import org.toop.framework.eventbus.EventFlow;
|
||||
import org.toop.framework.networking.connection.events.NetworkEvents;
|
||||
|
||||
public final class ServerView extends ViewWidget {
|
||||
private final String user;
|
||||
private final Consumer<String> onPlayerClicked;
|
||||
private final long clientId;
|
||||
|
||||
private final ListView<Button> listView;
|
||||
|
||||
public ServerView(String user, Consumer<String> onPlayerClicked) {
|
||||
public ServerView(String user, Consumer<String> onPlayerClicked, long clientId) {
|
||||
this.user = user;
|
||||
this.onPlayerClicked = onPlayerClicked;
|
||||
this.clientId = clientId;
|
||||
|
||||
this.listView = new ListView<>();
|
||||
|
||||
@@ -29,9 +33,16 @@ public final class ServerView extends ViewWidget {
|
||||
private void setupLayout() {
|
||||
var playerHeader = Primitive.header(user, false);
|
||||
|
||||
Button subscribeButton = Primitive.button(
|
||||
"subscribe",
|
||||
() -> new EventFlow().addPostEvent(new NetworkEvents.SendSubscribe(clientId, "reversi")).postEvent(),
|
||||
false
|
||||
); // TODO localize
|
||||
|
||||
var playerListSection = Primitive.vbox(
|
||||
playerHeader,
|
||||
Primitive.separator(),
|
||||
subscribeButton,
|
||||
listView
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user