AnsweredAssumed Answered

Messages not getting recieved

Question asked by Piyush on May 22, 2016
Latest reply on May 22, 2016 by Flow

Hello Everyone,

 

I am able to send the messages using below code, however I want to read the messages that I have newly typed in one of chat client Pidgin using the same username.
Below code is not giving any received message. Do I need to add another listener here?

 

public static void main(String args[]) throws SmackException, IOException, XMPPException, KeyManagementException, NoSuchAlgorithmException{
  // Create the configuration for this new connection

  XMPPTCPConnectionConfiguration.Builder configBuilder = XMPPTCPConnectionConfiguration.builder();
  //configBuilder.setDebuggerEnabled(true);
  configBuilder.setSendPresence(true);
  configBuilder.setUsernameAndPassword("pmittal", "pass");
  configBuilder.setResource("Piyushs-MacBook-Pro");
  configBuilder.setServiceName("oracle.com");
  configBuilder.setHost("stbeehive.oracle.com"); 
  configBuilder.setPort(5223);
  configBuilder.setSecurityMode(ConnectionConfiguration.SecurityMode.disabled);
  configBuilder.setSocketFactory(SSLSocketFactory.getDefault());
 

  connection = new XMPPTCPConnection(configBuilder.build());
  // Connect to the server
  System.out.println("Configuration done");
  connection.connect();
  System.out.println("Connection Established");
  // Log into the server
  connection.login();
  // Assume we've created an XMPPConnection name "connection"._
  ChatManager chatmanager = ChatManager.getInstanceFor(connection);
  Chat newChat = chatmanager.createChat("pmittal@oracle.com");
  newChat.sendMessage("Hello, how are you?");
  
  Chat chat = ChatManager.getInstanceFor(connection).createChat("pmittal@oracle.com", new ChatMessageListener() {
      public void processMessage(Chat chat, Message message) {
          // Print out any messages we get back to standard out.
          System.out.println("Received message: " + message);
           
      }
  });
  chat.sendMessage("Howdy!");
  connection.disconnect();
  }

Outcomes