JSkype ошибка отправки сообщения - PullRequest
0 голосов
/ 28 сентября 2010

Я пытаюсь запустить следующий код, но, к сожалению, сталкиваюсь с проблемами ошибок

package jskypeexample;

// import the JSkype packages
   import net.lamot.java.jskype.general.AbstractMessenger;
   import net.lamot.java.jskype.general.MessageListenerInterface;
   import net.lamot.java.jskype.windows.Messenger;
   import java.lang.Thread;
   import java.lang.Exception;

  /**
   *
   * @author swhite
   */
   public class JSkypeExample implements MessageListenerInterface {

   // create a messenger which we'll use for sending messages
   private AbstractMessenger msgr = null;

   /** Creates a new instance of JSkypeExample */
   public JSkypeExample() {

   msgr = new Messenger();
   msgr.addListener(this);
   msgr.initialize(); 
   try {
     // This number may vary on your system depending on the amount
     // of time required to initialize the msgr.
     Thread.sleep(1000);
     // send the Skype API text command
   msgr.sendMessage("Message seanmwhite Hello from UI Student");
     msgr.sendMessage("SEARCH FRIENDS");
   } catch (Exception e) {
     e.printStackTrace();
   }
   }

   public static void main(String[] args) {
     new JSkypeExample();
   }

   public void onMessageReceived(String str) {
     // This is where you will handle all strings that are returned.
     System.out.println(str);
   }

 }

Но когда я комментирую следующие строки, тогда он работает хорошо.

 msgr.initialize(); 
 msgr.sendMessage("Message seanmwhite Hello from UI Student");
 msgr.sendMessage("SEARCH FRIENDS");

Но я должен отправить команды, чтобы получить ответ.На самом деле я использую JSkype Api (API с открытым исходным кодом из Java).

1 Ответ

0 голосов
/ 29 сентября 2010

Вы должны установить логическое значение, которое ваша функция initilaze возвращает в true, или перехватить это выполнение, если оно ложно.

...