<file_sep>package io.github.devas;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;

class MessengerApp {

    private boolean isRunning = true;
    private Sender sender;
    private Receiver receiver;
    private Configuration conf = new Configuration(7777, "Anakin", "localhost", 8888);

    void startMessenger() throws IOException {
        Scanner sc = new Scanner(System.in);

        System.out.print("Listening port: ");
        conf.setListeningPort(sc.nextInt());
        receiver = new Receiver(conf.getListeningPort());

        System.out.print("Target port: ");
        conf.setTargetPort(sc.nextInt());
        sender = new Sender(conf.getUserName(), conf.getTargetIp(), conf.getTargetPort());

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        System.out.println("Chat started. Type '\\exit' to quit.");

        while (isRunning) {
            String input = br.readLine();
            if (input.equals("\\exit")) {
                receiver.stop();
                sender.stop();
                isRunning = false;
            } else {
                sender.sendMessage(input);
            }
        }
    }
}
<file_sep>package io.github.devas;

class Configuration {

    private int listeningPort;

    private String userName;
    private String targetIp;
    private int targetPort;

    Configuration(int listeningPort, String userName, String targetIp, int targetPort) {
        this.listeningPort = listeningPort;
        this.userName = userName;
        this.targetIp = targetIp;
        this.targetPort = targetPort;
    }

    int getListeningPort() {
        return listeningPort;
    }

    void setListeningPort(int listeningPort) {
        this.listeningPort = listeningPort;
    }

    String getUserName() {
        return userName;
    }

    void setUserName(String userName) {
        this.userName = userName;
    }

    String getTargetIp() {
        return targetIp;
    }

    void setTargetIp(String targetIp) {
        this.targetIp = targetIp;
    }

    int getTargetPort() {
        return targetPort;
    }

    void setTargetPort(int targetPort) {
        this.targetPort = targetPort;
    }
}
