Last active
August 29, 2015 14:25
-
-
Save vemacs/aa1565456b76022ed847 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); | |
| private Skype skype; | |
| public void loadSkype() { | |
| scheduler.scheduleAtFixedRate(new Runnable() { | |
| @Override | |
| public void run() { | |
| try { | |
| Skype oldSkype = skype; // get instance of old skype | |
| Skype newSkype = Skype.login(username, password); // Set up new skype | |
| System.out.println("Logged in with username " + username); | |
| newSkype.getEventDispatcher().registerListener(new Listener() { | |
| @EventHandler | |
| public void onMessage(final MessageReceivedEvent e) { | |
| } | |
| }); | |
| newSkype.subscribe(); | |
| skype = newSkype; // reassign new skype to current skype | |
| System.out.println("Reassigned new Skype"); | |
| if (oldSkype != null) { | |
| try { | |
| oldSkype.logout(); | |
| System.out.println("Logged out previous instance"); | |
| } catch (IOException ignored) { | |
| } | |
| } | |
| } catch (Exception e) { | |
| e.printStackTrace(); | |
| } | |
| } | |
| }, 0, 30, TimeUnit.MINUTES); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment