title: Cannot cast from Packet to Message using SMACK API
body: <p>I am having a weird issue of not being able to cast a packet into a message. I get an error at this line: <code>Message msg = (Message) arg0;</code> It says</p>
  
  <blockquote>
    <p>"Cannot cast from Packet to Message"</p>
  </blockquote>
  
  <p>//Code</p>
  
  <pre><code>     connection.connect();
       connection.login(uN, pw);
  
      PacketTypeFilter filter = new PacketTypeFilter(Message.class);
      PacketCollector myCollector = connection.createPacketCollector(filter);
      PacketListener myListener = new PacketListener(){
  
              @Override
              public void processPacket(Packet arg0) {
                  // TODO Auto-generated method stub
                  if(arg0 instanceof org.jivesoftware.smack.packet.Message){
                          Message msg = (Message) arg0;
                          }
                      }
  
                  };
      connection.addPacketListener(myListener, filter);
  </code></pre>