Not logged in. · Lost password · Register
Forum: agsXMPP RSS
jcdekoning #1
Member since Sep 2005 · 13 posts
Group memberships: Members
Show profile · Link to this post
Subject: Storing and loading XMPP Messages
When there is no connection available i want to store messages in a queue (which can be on the server or client). The messages in the queue are written to the file system to make sure that messages still remain when the server or client are switch off.

Storing XMPP Messages in not the problem. Just write the XML to the file system. The problem is loading the message and restoring the Message objects. I have a xml string which cannot be added as property of the constructor. What is the best way of creating a message from an xml string?

Should i use a XmlDocument and loop trough all the elements to read out all the different properties which can be used for a Message object of the agsXMPP library?
Alex #2
Member since Feb 2003 · 4442 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
hi jcdekoning,

good you give me some more details?
When you send a message to a user who is currently offline, the jabber/xmpp server stores this message offline and delivers it to the user once he comes online. So its a server job and you don't have to store the messages at all.

Or do you want to implement smth like a chat history and want to store the original xml of all message stanzas?
You can store the xml, but when you load it again with the DomLoader in agsXMPP you will have a "normal" XML Element and not a class of type Message. agsXMPP is using a Factory pattern for creating the correct classes from the stream. This pattern is implemented in the StreamParser and currently not reusable.

You could write your own factory if you want to load the xml from a file or string. But i think for messages only it would be easier to write the properties you need to a small SQL database (from, body, type etc...)

Close Smaller – Larger + Reply to this post:
Verification code: VeriCode Please enter the word from the image into the text field below. (Type the letters only, lower case is okay.)
Smileys: :-) ;-) :-D :-p :blush: :cool: :rolleyes: :huh: :-/ <_< :-( :'( :#: :scared: 8-( :nuts: :-O
Special characters:
Forum: agsXMPP RSS