Smack API - Read Chat History from Openfire Server
Asked Answered
R

2

4

How can I fetch chat log or chat history from Openfire server using Smack library into an Android application?

Redingote answered 9/7, 2011 at 13:30 Comment(1)
Have you found the answer? I have the same problem. My XMPP server supports storing the messages, but I can't find the smack clinet android API to retrieve those messages....Leaflet
S
-1

As far as I know, there is no storing of chat history in Openfire. You can only get offline messages sent by user (when they connect next time for example), but if you want to store the messages you can implement it yourself directly on the XMPP server (personally I did it using mongodb - it works great!).

But then, maybe I missed something in Openfire...

Saddler answered 11/7, 2011 at 23:7 Comment(9)
ya,you are right. my web developer already implement plugin on XMPP server to archive chat messages, but at client hand(or device hand) i didn't get any way to access that archive messages.Redingote
i am using smack api to implement chat functionality with in my android application, so i am looking for exact code through which i can retrieve chat history from XMPP server at device hand.Redingote
i am hopefully looking forward at your side to get reply on it as quick as possible.so please give me reply on it as soon as possible.Redingote
Well I personally do it by using mongodb, so if you decide to use mongodb as well you can just connect from your Android app to the mondodb on your server and query the collection from there.Saddler
Also, I don't know if it could help, but have you looked at the Monitoring plug-in? I didn't try it, but I guess if you use mysql for example to store the logs then it will be easy to fetch the logs from there on your Android app. Personally I find it easier to store in a database that I know how to query rather than to use API that I have no idea how to use ...Saddler
Hi Guillaume, i searched too much on this side, and not able to retrieve archived message from xmpp server..i read thoroughly all the apis available in smack library, but no one help me. If you can help me on the code snippet level, then may be that will help me to implement. please help me as quick as possible... i am totally frustrated from this implementation.Redingote
@Redingote as I said before, I am using MongoDB to store the messages on my server-side, which has nothing to do with XMPP/smack/history, it is just a no-sql database. So if you want to use this, please read first on this, try it out, and if you really don't see what to do I can help, but there's no link with XMPP once againSaddler
ya got it the point.. will ask from you, when i will move ahead into your way of implementation. thanks for co-operating with me.Redingote
Chat storing is available on openfire and you can get it using smack library. Here is how to do that : #39164181 and is server install plugin igniterealtime.org/projects/openfire/plugins/monitoring.jarAvictor
N
4

Openfire server can surely save chat histories. To turn it on, you should go to Server/Server Settings/Message Audit Policy and select Enable Message Auditing. As you can see there, messages will be held under the /.../openfire/logs folder in some kind of XML format. You can parse this XML and get your messages very easily

Neptune answered 14/3, 2012 at 8:49 Comment(7)
Actually I want to get that messages at client hand into my android application. I want to know the approach to retrieve them at client hand.Redingote
alpay, m trying to get chat histories from openfire, but unfortunately i searched arnd and could not find any api for it.Do you know which HTTP request is required?Lovett
I dont have access to the server(its at remote location), so I wont be able to use this solution.So I was just looking for a direct api to retrieve historyLovett
I haven' t tested but you should see this, and this. I hope they helpNeptune
Will the message be saved here even if user has disabled history from XMPP client?Skurnik
I am not sure what's the difference between your way and my way (posted as answer). Can you please clarify if you know?Skurnik
@AdilMalik Question asks how to "fetch" chat histories from Smack server into an Android application. But you shown just how to browse the messages on Smack server. How do you suppose him to fetch these messages into Android app? Furthermore you didn' t point out how he can turn message auditing on.Neptune
S
-1

As far as I know, there is no storing of chat history in Openfire. You can only get offline messages sent by user (when they connect next time for example), but if you want to store the messages you can implement it yourself directly on the XMPP server (personally I did it using mongodb - it works great!).

But then, maybe I missed something in Openfire...

Saddler answered 11/7, 2011 at 23:7 Comment(9)
ya,you are right. my web developer already implement plugin on XMPP server to archive chat messages, but at client hand(or device hand) i didn't get any way to access that archive messages.Redingote
i am using smack api to implement chat functionality with in my android application, so i am looking for exact code through which i can retrieve chat history from XMPP server at device hand.Redingote
i am hopefully looking forward at your side to get reply on it as quick as possible.so please give me reply on it as soon as possible.Redingote
Well I personally do it by using mongodb, so if you decide to use mongodb as well you can just connect from your Android app to the mondodb on your server and query the collection from there.Saddler
Also, I don't know if it could help, but have you looked at the Monitoring plug-in? I didn't try it, but I guess if you use mysql for example to store the logs then it will be easy to fetch the logs from there on your Android app. Personally I find it easier to store in a database that I know how to query rather than to use API that I have no idea how to use ...Saddler
Hi Guillaume, i searched too much on this side, and not able to retrieve archived message from xmpp server..i read thoroughly all the apis available in smack library, but no one help me. If you can help me on the code snippet level, then may be that will help me to implement. please help me as quick as possible... i am totally frustrated from this implementation.Redingote
@Redingote as I said before, I am using MongoDB to store the messages on my server-side, which has nothing to do with XMPP/smack/history, it is just a no-sql database. So if you want to use this, please read first on this, try it out, and if you really don't see what to do I can help, but there's no link with XMPP once againSaddler
ya got it the point.. will ask from you, when i will move ahead into your way of implementation. thanks for co-operating with me.Redingote
Chat storing is available on openfire and you can get it using smack library. Here is how to do that : #39164181 and is server install plugin igniterealtime.org/projects/openfire/plugins/monitoring.jarAvictor

© 2022 - 2024 — McMap. All rights reserved.