I am creating a chat application for Gtalk using the asmack api, and i want to get the messages when user goes offline, but gettting problems because of some problems in ServiceDiscoveryManager and its saying that feature not implemented(501) and tried to implements all the things which other users have same problem, but now i m getting this error. I am posting the code and logcat with this. any help appreciated.
ConnectionConfiguration connConfig = new ConnectionConfiguration(
host, Integer.parseInt(port), service);
connConfig.setSASLAuthenticationEnabled(true);
connConfig.setSendPresence(false);
connection = new XMPPConnection(connConfig);
connection.connect();
connection.login(username, password);
ServiceDiscoveryManager sdm= ServiceDiscoveryManager.getInstanceFor(connection);
mOfflineMessageManager = new OfflineMessageManager(connection);
offlinemsgs = mOfflineMessageManager.getMessageCount();
this is the code where I call for offline messages just after login, and below is the response in logcat error:
03-16 11:26:53.871: W/System.err(325): feature-not-implemented(501)
03-16 11:26:53.881: W/System.err(325): at org.jivesoftware.smackx.OfflineMessageManager.getMessages(OfflineMessageManager.java:210)
03-16 11:26:53.881: W/System.err(325): at com.apache.android.xmpp.MainScreen.getOfflinemessages(MainScreen.java:911)
03-16 11:26:53.881: W/System.err(325): at com.apache.android.xmpp.MainScreen$LogIn.doInBackground(MainScreen.java:612)
03-16 11:26:53.881: W/System.err(325): at com.apache.android.xmpp.MainScreen$LogIn.doInBackground(MainScreen.java:1)
03-16 11:26:53.881: W/System.err(325): at android.os.AsyncTask$2.call(AsyncTask.java:185)
03-16 11:26:53.881: W/System.err(325): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
03-16 11:26:53.881: W/System.err(325): at java.util.concurrent.FutureTask.run(FutureTask.java:137)
03-16 11:26:53.881: W/System.err(325): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1068)
03-16 11:26:53.881: W/System.err(325): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:561)
03-16 11:26:53.891: W/System.err(325): at java.lang.Thread.run(Thread.java:1096)
please help on this, trying to get the solution from many days but cant find any solution.
try this :
ConnectionConfiguration connConfig = new ConnectionConfiguration(
host, Integer.parseInt(port), service);
connConfig.setSASLAuthenticationEnabled(true);
connConfig.setSendPresence(false);
connection = new XMPPConnection(connConfig);
connection.connect();
connection.login(username, password);
ServiceDiscoveryManager sdm= ServiceDiscoveryManager.getInstanceFor(connection);
////////////////////////////
OfflineMessageManager offlineManager = new OfflineMessageManager(
Client.getConnection());
try {
Iterator<org.jivesoftware.smack.packet.Message> it = offlineManager
.getMessages();
System.out.println(offlineManager.supportsFlexibleRetrieval());
System.out.println("Number of offline messages:: " + offlineManager.getMessageCount());
Map<String,ArrayList<Message>> offlineMsgs = new HashMap<String,ArrayList<Message>>();
while (it.hasNext()) {
org.jivesoftware.smack.packet.Message message = it.next();
System.out
.println("receive offline messages, the Received from [" + message.getFrom()
+ "] the message:" + message.getBody());
String fromUser = message.getFrom().split("/")[0];
if(offlineMsgs.containsKey(fromUser))
{
offlineMsgs.get(fromUser).add(message);
}else{
ArrayList<Message> temp = new ArrayList<Message>();
temp.add(message);
offlineMsgs.put(fromUser, temp);
}
}
/ / Deal with a collection of offline messages ...
Set<String> keys = offlineMsgs.keySet();
Iterator<String> offIt = keys.iterator();
while(offIt.hasNext())
{
String key = offIt.next();
ArrayList<Message> ms = offlineMsgs.get(key);
TelFrame tel = new TelFrame(key);
ChatFrameThread cft = new ChatFrameThread(key, null);
cft.setTel(tel);
cft.start();
for (int i = 0; i < ms.size(); i++) {
tel.messageReceiveHandler(ms.get(i));
}
}
offlineManager.deleteMessages();
} catch (Exception e) {
e.printStackTrace();
}
See this Like : http://community.igniterealtime.org
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With