use of com.gianlu.pyxreborn.Models.Client.CUser in project PretendYoureXyzzyReborn by devgianlu.
the class MainUI method refreshUsersList.
@FXML
public void refreshUsersList() {
JsonObject resp;
try {
resp = client.sendMessageBlocking(client.createRequest(Operations.LIST_USERS));
} catch (InterruptedException | PyxException ex) {
UIClient.notifyException(ex);
return;
}
JsonArray usersArray = resp.getAsJsonArray(Fields.USERS_LIST.toString());
ObservableList<CUser> users = new ObservableListWrapper<>(Utils.toList(usersArray, CUser.class));
usersList.setItems(users);
}
use of com.gianlu.pyxreborn.Models.Client.CUser in project PretendYoureXyzzyReborn by devgianlu.
the class RegisterUI method register.
@FXML
public void register() {
String nickname = this.nickname.getText();
try {
Client client = new Client(new URI(address.getText()), nickname, null, admin.isSelected() ? adminCode.getText() : null);
if (client.connectBlocking()) {
CUser me;
try {
me = new CUser(client.sendMessageBlocking(client.createRequest(Operations.GET_ME)).getAsJsonObject(Fields.USER.toString()));
} catch (PyxException ex) {
UIClient.notifyException(ex);
return;
}
stage.close();
GlobalChatUI.show(client);
MainUI.show(client, me);
} else {
new Alert(Alert.AlertType.ERROR, "Failed connecting! Nickname may be invalid or server may be full.").show();
}
} catch (InterruptedException | URISyntaxException ex) {
UIClient.notifyException(ex);
}
}
Aggregations