import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.net.SocketException;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.Arrays;

public class UserListeningThread extends Thread{
	
	private User myUser;
	
	public UserListeningThread(String s,User user) { 
		super(s);
		this.myUser = user;
	}
	
	public void run(){ 
		while(true) {
		
			DatagramSocket dgramSocket = null;
			try {
				dgramSocket = new DatagramSocket(myUser.getNport(),myUser.getAddIP());
			} catch (SocketException e) {
				e.printStackTrace();
			}
			
			byte[] buffer = new byte[256];
			DatagramPacket inPacket= new DatagramPacket(buffer, buffer.length);
			try {
				dgramSocket.receive(inPacket);
			} catch (IOException e) {
				e.printStackTrace();
			}
			buffer = inPacket.getData();
			String listPseudo = new String(buffer);
			System.out.println(listPseudo);
		}
	}
}



