public synchronized BOSHMessageEvent waitForEvent() throws InterruptedException {
            while(eventsReceived.isEmpty())
                wait();
            return eventsReceived.remove();
        }