package smprot;

import smserve_main.Messagequeuehandler;
import structures.Message;

public class Messagehandler {
	Messagequeuehandler mh;
	public Messagehandler() {
		mh = new Messagequeuehandler();
	}

	
	public void addPlainMessage(String pFromUser, String pMessagestring) throws Exception {
		this.addMessage(pMessagestring.split(":")[1].split(";")[0], new Message(pFromUser, 
				pMessagestring.split(":")[1].split(";")[1]));
	}
	
	public void addMessage(String pUser, Message pMess) throws Exception {
		this.mh.getMessagequeue(pUser).messages.add(pMess);
	}
	
	public void delMessage(String pUser, int pId) throws Exception {
		this.mh.getMessagequeue(pUser).messages.remove(pId);
	}
	
	public void getMessage(String pUser, int pId) throws Exception {
		this.mh.getMessagequeue(pUser).messages.get(pId);
	}
}
