public ClientHandler(Socket sock, MultiQueue<Message> queue, Database database) {
		this.socket = sock;
		this.queues = queue;
		this.database = database;
		
		List<RelayMessage> recent = null;
	
		try {
			database.incrementLogins();
			recent = database.getRecent();
		} catch(SQLException e) {
			e.printStackTrace();
		}
		
		messages = new MessageQueue<Message>();
		
		if(recent != null) {
			for(int i = recent.size() - 1; i >= 0; i--) {
				messages.put(recent.get(i));
			}
		}
		
		queue.register(messages);
		
		nick = String.format("Anonymous%5d", rand.nextInt(100000));
		StatusMessage status = new StatusMessage(String.format("[%s] [%s] Connected.", nick, sock.getInetAddress().getHostName()));
		queue.put(status);
		
		Thread receiverThread = new Thread(new Receiver());
		receiverThread.start();
		
		Thread transmitterThread = new Thread(new Transmitter());
		transmitterThread.start();
		
		try {
			receiverThread.join();
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		
		try {
			socket.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}