<commit_before>package nl.mawoo.smokesignal.gui;

import nl.mawoo.smokesignal.networking.Peer;

import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Scanner;
import java.util.function.Consumer;

/**
 * Controls every in and output of the application
 *
 * @author <NAME>
 */
public class Cli extends Thread {
    private final Scanner scanner;
    private final List<Peer> peers = new ArrayList<>();
    private final String handle;
    private final Consumer<String> connectCallback;

    public Cli(Scanner scanner, String handle, Consumer<String> connectCallback) {
        this.scanner = scanner;
        this.handle = handle;
        this.connectCallback = connectCallback;
    }

    public void addPeer(Peer peer) {
        peer.addMessageListener(System.out::println);
        peers.add(peer);
        say("welcome in the network", peer);
    }

    private void say(String message, Peer peer) {
        peer.send(MessageFormat.format("{0,time,medium} [{1}] - {2}", new Date(), handle, message));
    }

    private void sayToAll(String message) {
        for (Peer peer : peers) {
            say(message, peer);
        }
    }

    @Override
    public void run() {
        while (scanner.hasNextLine()) {

            String line = scanner.nextLine();

            // Als dit met een slash begint dan verbinden we met die host
            if (line.startsWith("/")) {
                connectCallback.accept(line.substring(1));
            } else {
                // Dus nu gaan we gewoon alle user input sturen naar alle peers
                sayToAll(line);
            }

        }
    }
}<commit_msg>remove comments<commit_after>package nl.mawoo.smokesignal.gui;

import nl.mawoo.smokesignal.networking.Peer;

import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Scanner;
import java.util.function.Consumer;

/**
 * Controls every in and output of the application
 *
 * @author <NAME>
 */
public class Cli extends Thread {
    private final Scanner scanner;
    private final List<Peer> peers = new ArrayList<>();
    private final String handle;
    private final Consumer<String> connectCallback;

    public Cli(Scanner scanner, String handle, Consumer<String> connectCallback) {
        this.scanner = scanner;
        this.handle = handle;
        this.connectCallback = connectCallback;
    }

    public void addPeer(Peer peer) {
        peer.addMessageListener(System.out::println);
        peers.add(peer);
        say("welcome in the network", peer);
    }

    private void say(String message, Peer peer) {
        peer.send(MessageFormat.format("{0,time,medium} [{1}] - {2}", new Date(), handle, message));
    }

    private void sayToAll(String message) {
        for (Peer peer : peers) {
            say(message, peer);
        }
    }

    @Override
    public void run() {
        while (scanner.hasNextLine()) {

            String line = scanner.nextLine();
            if (line.startsWith("/")) {
                connectCallback.accept(line.substring(1));
            } else {
                sayToAll(line);
            }
        }
    }
}
{'fraction_non_alphanumeric': 0.11131840796019901, 'fraction_numerical': 0.0024875621890547263, 'mean_word_length': 2.4816017316017316, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7051649', 'n_tokens_mistral': 934, 'n_tokens_neox': 901, 'n_words': 245}