2010-09-28 3 views
0

Je suis en train d'exécuter le code suivant, mais malheureusement face à des problèmes d'erreurerreur JSkype envoyer un message

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); 
    } 

} 

Mais quand je commente les lignes suivantes, alors il fonctionne bien.

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

Mais je dois envoyer des commandes pour recevoir la réponse. En fait, j'utilise JSkype Api (API open source de Java).

Répondre

0

Vous devez définir votre valeur booléenne que votre fonction initilaze retourne à true ou attraper cette extension si elle est false.