<commit_before>package com.hackbridge.viral;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.net.Socket;

public class MessageReceiver extends Thread {
    
    private Message mess;
    private Socket s;

    public MessageReceiver(Socket s) {
        this.s = s;
    }
    @Override
    public void run() {
        try {
            ObjectInputStream ois = new ObjectInputStream(s.getInputStream());
            while (true) {
                mess = null;
                try {
                    while (mess == null) {
                        mess = (Message) ois.readObject();
                    }
                    if (mess instanceof ChangeMessage) {
                        System.out.println("Got a ChangeMessage");
                        NetworkTest.awareState = ((ChangeMessage) mess).getAware();
                        NetworkTest.physState = ((ChangeMessage) mess).getInfected();
                        // TODO: Stanoje, I need a method for this!
                    } else if (mess instanceof StopMessage) {
                        System.out.println("Got a StopMessage");
                        // TODO: Stanoje, tell me what the 'stop round' method is!
                    } else if (mess instanceof StartMessage) {
                        NetworkTest.id = ((StartMessage) mess).getId();
                        NetworkTest.awareState = ((ChangeMessage) mess).getAware();
                        NetworkTest.physState = ((ChangeMessage) mess).getInfected();
                        System.out.println("My name is " + NetworkTest.id); 
                        NetworkTest.state++;
                        // TODO: Stanoje, act!
                    } else {
                        System.out.println("Unexpected Message object");
                        // TODO: do something useful
                    }
                } catch (ClassNotFoundException e) {
                    System.out.println("Unknown class received from server");
                    // we're doing this silently
                }
            }
        } catch (IOException e) {
            System.out.println("IOException caught in MessageReceiver, thread exiting");
            return;
        }
    }

}<commit_msg>MessageReceiver handles all messages<commit_after>package com.hackbridge.viral;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.net.Socket;

public class MessageReceiver extends Thread {
    
    private Message mess;
    private Socket s;
    private MainActivity ma;

    public MessageReceiver(MainActivity ma, Socket s) {
        this.ma = ma;
        this.s = s;
    }
    @Override
    public void run() {
        try {
            ObjectInputStream ois = new ObjectInputStream(s.getInputStream());
            while (true) {
                mess = null;
                try {
                    while (mess == null) {
                        mess = (Message) ois.readObject();
                    }
                    if (mess instanceof ChangeMessage) {
                        System.out.println("Got a ChangeMessage");
                        ma.setAwareness(((ChangeMessage) mess).getAware());
                        ma.setInfected(((ChangeMessage) mess).getInfected());
                    } else if (mess instanceof StopMessage) {
                        System.out.println("Got a StopMessage");
                        ma.setRoundOn(false);
                    } else if (mess instanceof StartMessage) {
                        System.out.println("Got a StartMessage"); 
                        ma.setIdentity(((StartMessage) mess).getId());
                        ma.setAwareness(((StartMessage) mess).getAware());
                        ma.setInfected(((StartMessage) mess).getInfected());
                        ma.setRoundOn(((StartMessage) mess).isRunning());
                    } else {
                        System.out.println("Unexpected Message object");
                        // treated silently
                    }
                } catch (ClassNotFoundException e) {
                    System.out.println("Unknown class received from server");
                    // we're doing this silently
                }
            }
        } catch (IOException e) {
            System.out.println("IOException caught in MessageReceiver, thread exiting");
            return;
        }
    }

}
{'fraction_non_alphanumeric': 0.09403460837887068, 'fraction_numerical': 0.0, 'mean_word_length': 1.378451543042772, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4664601', 'n_tokens_mistral': 1041, 'n_tokens_neox': 956, 'n_words': 253}