package model;

import java.io.IOException;
import java.net.Socket;
import java.util.ArrayList;

public class Chat {
	
	/*** ATTRIBUTS ***/
	private RemoteUser remoteUser;
	private ArrayList<Message> messages = new ArrayList<Message>();
	private Socket userSocket;
	private Boolean active = false;
	
	/**
	 *  Constructor of Chat (local)
	 * @parametres
	 * 	 	@param remoteUser : remoteUser => référence de l'utilisateur distant
		 * @description
	 * <p>
	 * 		
	 * </p>
	 */
	public Chat(RemoteUser rm) {
		this.remoteUser=rm;
	}
	
	/*** GETTERS ***/ 
	public RemoteUser getRemoteUser() {
		return remoteUser;
	}
	public ArrayList<Message> getMessages() {
		return messages;
	}
	public Socket getUserSocket() {
		return userSocket;
	}
	public Boolean getActive() {
		return active;
	}
	
	/*** SETTERS ***/
	public void setRemoteUser(RemoteUser rm) {
		this.remoteUser = rm;
	}
	public void setSocket(Socket link) {
		this.userSocket = link;
	}
	public void addMessage(Message msg) {
		this.messages.add(msg);
	}
	public void activate() {
		this.active = true;
	}
	
	public void close() {
		this.active = false;
		try {
			this.userSocket.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
		
	}
	
}
