package org.mynonglam.dao;

import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.CharBuffer;
import org.apache.catalina.websocket.MessageInbound;
import org.apache.catalina.websocket.WsOutbound;
import org.mynonglam.entitys.Client;
import org.mynonglam.server.Notificate;

public class Notification extends MessageInbound {
	private String username;
	private Client client;
	public Notification(String username){
		this.username = username;
	}
	
	@Override
	protected void onBinaryMessage(ByteBuffer arg0) throws IOException {
		// TODO Auto-generated method stub
		
	}

	@Override
	protected void onTextMessage(CharBuffer cb) throws IOException {
	}

	@Override
	protected void onClose(int status) {
		Notificate.clientListNotfi.remove(this.client);
	}
	
	@Override
	protected void onOpen(WsOutbound out) {
		this.client = new Client(this.username, out);
		Notificate.clientListNotfi.add(client);
	}
}
