<commit_before>package es.deusto.ingenieria.ssdd.chat;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;


public class Handler extends Thread {

	boolean ejecutar = true;
	DatagramPacket request, reply;
	DatagramSocket udpSocket;
	byte[] buffer;
	Brain brain;
	
	
	public Handler(DatagramPacket request, DatagramPacket reply, byte[] buffer, DatagramSocket udpSocket) {
		this.request = request;
		this.reply = reply;
		this.buffer = buffer;
		this.udpSocket = udpSocket;
		this.brain = new Brain(this);
	}

	public void stop(boolean stop){
		ejecutar = stop;
	}
	
	public void run(){
		while (ejecutar) {
			try{
			request = new DatagramPacket(buffer, buffer.length);
			udpSocket.receive(request);				
			System.out.println(" - Received a request from '" + request.getAddress().getHostAddress() + ":" + request.getPort() + 
			                   "' -> " + new String(request.getData()));
			brain.receivedMessage(new String(request.getData()), request.getAddress().getHostAddress(), request.getPort());
			
			} catch (IOException e) {
				System.err.println("# UDPServer IO error: " + e.getMessage());
			}
		}
	}

	public void sendMessage(String message, String ip, int port) {
		try {
			reply = new DatagramPacket(message.getBytes(), message.getBytes().length, InetAddress.getByName(ip), port);
			udpSocket.send(reply);
			System.out.println(" - Sent a message to '" + ip + "' -> " + message);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

}<commit_msg>handler<commit_after>package es.deusto.ingenieria.ssdd.chat;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;


public class Handler extends Thread {

	boolean ejecutar = true;
	DatagramPacket request, reply;
	DatagramSocket udpSocket;
	byte[] buffer;
	Brain brain;
	
	
	public Handler(DatagramPacket request, DatagramPacket reply, byte[] buffer, DatagramSocket udpSocket) {
		this.request = request;
		this.reply = reply;
		this.buffer = buffer;
		this.udpSocket = udpSocket;
		this.brain = new Brain(this);
	}

	public void stop(boolean stop){
		ejecutar = stop;
	}
	
	public void run(){
		while (ejecutar) {
			try{
			request = new DatagramPacket(buffer, buffer.length);
			udpSocket.receive(request);				
			System.out.println(" - Received a request from '" + request.getAddress().getHostAddress() + ":" + request.getPort() + 
			                   "' -> " + new String(request.getData()));
			brain.receivedMessage(new String(request.getData()), request.getAddress().getHostAddress(), request.getPort());
			
			} catch (IOException e) {
				System.err.println("# UDPServer IO error: " + e.getMessage());
			}
		}
	}

	public void sendMessage(String message, String ip, int port) {
		try {
			reply = new DatagramPacket(message.getBytes(), message.getBytes().length, InetAddress.getByName(ip), port);
			udpSocket.send(reply);
			System.out.println(" - Sent a message to '" + ip + "' Port: "+port+" -> " + message);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

}
{'fraction_non_alphanumeric': 0.13557722554262347, 'fraction_numerical': 0.0, 'mean_word_length': 3.7963800904977374, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 7, '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': '5009390', 'n_tokens_mistral': 1112, 'n_tokens_neox': 996, 'n_words': 234}