You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by Niklas Gustavsson <ni...@protocol7.com> on 2009/09/02 23:04:45 UTC

[Vysper] Random thoughts on message stanza handling

Hi

On hacking a bit on Vysper, I got some random thoughts:
* How about making MessageStanza.getSubjects() and
MessageStanza.getBodies() return a Map<String, String> rather than
Map<String, XMLElement>? Looking at the XML schema for <message>, it
seems that body and subject elements can only contain text.
* Should we add a StanzaBuilder.createMessageStanza() that takes
Map<String, String> for subjects and bodies?
* Also, how about adding a StanzaBuilder.createMessageStanza() that
takes a Delay object for adding a delay element?

/niklas

Re: [Vysper] Random thoughts on message stanza handling

Posted by Bernd Fondermann <bf...@brainlounge.de>.
Niklas Gustavsson wrote:
> On Thu, Sep 3, 2009 at 10:07 AM, Bernd Fondermann<bf...@brainlounge.de> wrote:
>>> * How about making MessageStanza.getSubjects() and
>>> MessageStanza.getBodies() return a Map<String, String> rather than
>>> Map<String, XMLElement>? Looking at the XML schema for <message>, it
>>> seems that body and subject elements can only contain text.
>> the XML schemas are not normative.
> 
> The text also states the same thing, see for subject:
> http://tools.ietf.org/html/draft-saintandre-rfc3921bis-08#section-5.2.4
> 
> "The <subject/> element MUST NOT contain mixed content".
> 
> For body, the text is probably the same, but is cut of in the document.
> 
>> rather, body elements can actually contain XML, see
>> http://xmpp.org/extensions/xep-0071.html
> 
> Interesting, that means my suggestion would not work. Retracting my
> suggestion :-)

It's probably depending on the xmlns. body with default xmlns can only
contain text.


>>> * Should we add a StanzaBuilder.createMessageStanza() that takes
>>> Map<String, String> for subjects and bodies?
>> we could. but where do we actually create pristine message stanzas?
> 
> Right, might not be all that common.
> 
>>> * Also, how about adding a StanzaBuilder.createMessageStanza() that
>>> takes a Delay object for adding a delay element?
>> What would be the use case, MUC history?
> 
> Yes, exactly. In this case the delayed delivery is quite simple since
> it just a matter of adding on the delay element from the discussion
> history.

So you would need to create a clone of the original message and add a
delay element. Keep in mind that the message might (=will) contain
arbitrary payload which you'd need to carry with you.

If it's simple to add in the MUC case, do it. We can always factor it
out later.

Please note there are utilities for generating XEP conformant date
strings in o.a.v.xmpp.datetime.DateTimeProfile

  Bernd

Re: [Vysper] Random thoughts on message stanza handling

Posted by Niklas Gustavsson <ni...@protocol7.com>.
On Thu, Sep 3, 2009 at 10:07 AM, Bernd Fondermann<bf...@brainlounge.de> wrote:
>> * How about making MessageStanza.getSubjects() and
>> MessageStanza.getBodies() return a Map<String, String> rather than
>> Map<String, XMLElement>? Looking at the XML schema for <message>, it
>> seems that body and subject elements can only contain text.
>
> the XML schemas are not normative.

The text also states the same thing, see for subject:
http://tools.ietf.org/html/draft-saintandre-rfc3921bis-08#section-5.2.4

"The <subject/> element MUST NOT contain mixed content".

For body, the text is probably the same, but is cut of in the document.

> rather, body elements can actually contain XML, see
> http://xmpp.org/extensions/xep-0071.html

Interesting, that means my suggestion would not work. Retracting my
suggestion :-)

>> * Should we add a StanzaBuilder.createMessageStanza() that takes
>> Map<String, String> for subjects and bodies?
>
> we could. but where do we actually create pristine message stanzas?

Right, might not be all that common.

>> * Also, how about adding a StanzaBuilder.createMessageStanza() that
>> takes a Delay object for adding a delay element?
>
> What would be the use case, MUC history?

Yes, exactly. In this case the delayed delivery is quite simple since
it just a matter of adding on the delay element from the discussion
history.

/niklas

Re: [Vysper] Random thoughts on message stanza handling

Posted by Bernd Fondermann <bf...@brainlounge.de>.
Niklas Gustavsson wrote:
> Hi
> 
> On hacking a bit on Vysper, I got some random thoughts:
> * How about making MessageStanza.getSubjects() and
> MessageStanza.getBodies() return a Map<String, String> rather than
> Map<String, XMLElement>? Looking at the XML schema for <message>, it
> seems that body and subject elements can only contain text.

the XML schemas are not normative.
rather, body elements can actually contain XML, see
http://xmpp.org/extensions/xep-0071.html

> * Should we add a StanzaBuilder.createMessageStanza() that takes
> Map<String, String> for subjects and bodies?

we could. but where do we actually create pristine message stanzas?

> * Also, how about adding a StanzaBuilder.createMessageStanza() that
> takes a Delay object for adding a delay element?

What would be the use case, MUC history?
When I think about Delayed Delivery[1,2], I think of a some special
runtime service code which is responsible for
+ adding delay elements to stanzas
+ pruging stanzas which have expired
+ storing them (serialization)
+ unserializing them
+ putting them on the wire

Right now, I think it's making sense to encapsulate this.

  Bernd

[1] http://xmpp.org/extensions/xep-0203.html
[2] http://xmpp.org/extensions/xep-0160.html