Search in sources :

Example 1 with Client

use of com.gianlu.pyxreborn.client.Client 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);
    }
}
Also used : CUser(com.gianlu.pyxreborn.Models.Client.CUser) Alert(javafx.scene.control.Alert) PyxException(com.gianlu.pyxreborn.Exceptions.PyxException) URISyntaxException(java.net.URISyntaxException) Client(com.gianlu.pyxreborn.client.Client) URI(java.net.URI) FXML(javafx.fxml.FXML)

Aggregations

PyxException (com.gianlu.pyxreborn.Exceptions.PyxException)1 CUser (com.gianlu.pyxreborn.Models.Client.CUser)1 Client (com.gianlu.pyxreborn.client.Client)1 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 FXML (javafx.fxml.FXML)1 Alert (javafx.scene.control.Alert)1