<commit_before>package com.cst242.finalproject.server.model;

import com.cst242.finalproject.server.viewcontroller.PrimaryWindow;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author <NAME>
 */
public class Server implements WindowListener {

    private static final int PORT = 9090;

    private ServerSocket serverSocket;    
    
    private List<ServerRoom> rooms;

    @SuppressWarnings({"CallToThreadStartDuringObjectConstruction", "LeakingThisInConstructor"})
    public Server(PrimaryWindow window) {                
        try {
            // add window listener to shutdown threads when closing
            window.addWindowListener(this);

            serverSocket = new ServerSocket(PORT);
            window.appendLog("Server started:  %s%n", new Date());

            // Start default rooms and add to list array
            rooms = new ArrayList<>();

            ServerRoom room = new ServerRoom("All_Chat", 9091, window);
            room.start();
            rooms.add(room);

            this.sleep();

            ServerRoom room2 = new ServerRoom("Everything_Java", 9092, window);
            room2.start();
            rooms.add(room2);

            this.sleep();

            ServerRoom room3 = new ServerRoom("Computer_Science", 9093, window);
            room3.start();
            rooms.add(room3);

            this.sleep();

            ServerRoom room4 = new ServerRoom("Conspiracy", 9094, window);
            room4.start();
            rooms.add(room4);

        } catch (IOException ex) {
            window.appendLog("Server error exit and restart to try again:  %s%n", ex);
            Logger.getLogger(Server.class.getName()).log(Level.SEVERE, null, ex);
            return;
        }

        for (;;) {
            
            try {
                Socket clientSocket = serverSocket.accept();
                Thread thread = new ServerThread(clientSocket, window, rooms);
                thread.start();
            } catch (IOException ex) {
                window.appendLog("Failed to connect client: %s", new Date());
                Logger.getLogger(Server.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
        
    }

    @Override
    public void windowOpened(WindowEvent e) {

    }

    @Override
    public void windowClosing(WindowEvent e) {
        for (ServerRoom room : this.rooms) {
            room.shutDown();
        }
    }

    @Override
    public void windowClosed(WindowEvent e) {

    }

    @Override
    public void windowIconified(WindowEvent e) {

    }<commit_msg>Worked on the logon logoff bug still no luck looking for help<commit_after>package com.cst242.finalproject.server.model;

import com.cst242.finalproject.server.viewcontroller.PrimaryWindow;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import java.net.SocketException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author <NAME>
 */
public class Server implements WindowListener {

    private static final int PORT = 9090;

    private ServerSocket serverSocket;

    private List<ServerRoom> rooms;

    @SuppressWarnings({"CallToThreadStartDuringObjectConstruction", "LeakingThisInConstructor"})
    public Server(PrimaryWindow window) {
        try {
            // add window listener to shutdown threads when closing
            window.addWindowListener(this);

            serverSocket = new ServerSocket(PORT);
            window.appendLog("Server started:  %s%n", new Date());

            // Start default rooms and add to list array
            rooms = new ArrayList<>();

            ServerRoom room = new ServerRoom("All_Chat", 9091, window);
            room.start();
            rooms.add(room);

            this.sleep();

            ServerRoom room2 = new ServerRoom("Everything_Java", 9092, window);
            room2.start();
            rooms.add(room2);

            this.sleep();

            ServerRoom room3 = new ServerRoom("Computer_Science", 9093, window);
            room3.start();
            rooms.add(room3);

            this.sleep();

            ServerRoom room4 = new ServerRoom("Conspiracy", 9094, window);
            room4.start();
            rooms.add(room4);

        } catch (IOException ex) {
            window.appendLog("Server error exit and restart to try again:  %s%n", ex);
            Logger.getLogger(Server.class.getName()).log(Level.SEVERE, null, ex);
            return;
        }

        for (;;) {
            try {
                Socket clientSocket = serverSocket.accept();
                Thread thread = new ServerThread(clientSocket, window, rooms);
                thread.start();
            } catch (SocketException e) {
                // window is closing so break from loop
                break;
            } catch (IOException ex) {
                this.sleep();
                window.appendLog("Failed to connect client: %s", new Date());
                Logger.getLogger(Server.class.getName()).log(Level.SEVERE, null, ex);
            }
        }

    }

    @Override
    public void windowOpened(WindowEvent e) {

    }

    @Override
    public void windowClosing(WindowEvent e) {

        // close chat rooms
        for (ServerRoom room : this.rooms) {
            room.shutDown();
        }

        // close server socket
        if (this.serverSocket != null) {
            try {
                this.serverSocket.close();
            } catch (IOException ex) {
                Logger.getLogger(Server.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    }

    @Override
    public void windowClosed(WindowEvent e) {

    }

    @Override
    public void windowIconified(WindowEvent e) {

    }
{'fraction_non_alphanumeric': 0.10533181151149519, 'fraction_numerical': 0.01141366378607533, 'mean_word_length': 2.068534267133567, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '1090047', 'n_tokens_mistral': 1700, 'n_tokens_neox': 1581, 'n_words': 400}