public static void main(String[] args) throws SkypeException, InterruptedException { Thread.setDefaultUncaughtExceptionHandler(new UncaughtHandler()); final ContactListFrame contactListFrame = new ContactListFrame(SkypeApp.getContacts()); final Application application = SkypeApp.getApp(); final SkypeBridge skypeBridge = new SkypeBridge(SkypeApp.getOwnId()); contactListFrame.setContactListSelectedListener( new ContactListSelected() { @Override public void selected(List<String> selectedValuesList) { if (selectedValuesList.size() == 0) { JOptionPane.showMessageDialog(null, "Select at least one contact."); return; } contactListFrame.close(); skypeBridge.setServer(); skypeBridge.setInvited(selectedValuesList); SkypeApp.connectToIds(selectedValuesList); } }); application.addApplicationListener(skypeBridge); }
private void checkDisconnect(Application application, Stream stream) throws Exception { final Object lock = new Object(); final boolean[] result = new boolean[1]; application.addApplicationListener( new ApplicationAdapter() { @Override public void disconnected(Stream stream) throws SkypeException { result[0] = true; synchronized (lock) { lock.notify(); } } }); synchronized (lock) { stream.write("disconnect"); try { lock.wait(10000); } catch (InterruptedException e) { fail(); } } assertTrue(result[0]); }