Showing posts with label schema. Show all posts
Showing posts with label schema. Show all posts

Friday, June 8, 2007

How SPS's sidebar can display same message as http://apps.sameplace.cc/chat/chat.xhtml?

Try to log in with a friend, then activate SPS's chat app through Connect > Misc > Chat (new page). You can chat on the sidebar and it will display the same message also in the right panel, and vice-versa. How does this work?
- It's because of the SCHEMA.
- once you follow SPS's schema, its no problem :D

- SPS's xmpp schemas:
- sender sends message, and get this:
--------------------------------------------------------------------------------
<message to="me@gmail.com/Browser" type="chat" id="1024">
<x xmlns="jabber:x:event">
<composing/>
</x>
<active xmlns="http://jabber.org/protocol/chatstates"/>
<body>mesend this in SPS </body>
<html xmlns="http://jabber.org/protocol/xhtml-im">
<body xmlns="http://www.w3.org/1999/xhtml">mesend this in SPS</body>
</html>
</message>
--------------------------------------------------------------------------------

- receiver receives message, and get this:
--------------------------------------------------------------------------------
<message to="me@gmail.com/Browser" type="chat" id="1024" from="u@gmail.com/SamePlace">
<x xmlns="jabber:x:event">
<composing/>
</x>
<active xmlns="http://jabber.org/protocol/chatstates"/>
<body>u send this in SPS </body>
<html xmlns="http://jabber.org/protocol/xhtml-im">
<body xmlns="http://www.w3.org/1999/xhtml">u send this in SPS</body>
</html>
<nos:x xmlns:nos="google:nosave" value="disabled"/>
<arc:record xmlns:arc="http://jabber.org/protocol/archive" otr="false"/>
</message>
--------------------------------------------------------------------------------

- Schema manipulating:
--------------------------------------------------------------------------------
stanza = <message to="me@gmail.com/Browser" type="chat" id="1024" from="u@gmail.com/SamePlace">
<x xmlns="jabber:x:event">
<composing/>
</x>
<active xmlns="http://jabber.org/protocol/chatstates"/>
<body>u send this in SPS </body>
<html xmlns="http://jabber.org/protocol/xhtml-im">
<body xmlns="http://www.w3.org/1999/xhtml">u send this in SPS</body>
</html>
<nos:x xmlns:nos="google:nosave" value="disabled"/>
<arc:record xmlns:arc="http://jabber.org/protocol/archive" otr="false"/>
</message>

stanza.@to = me@gmail.com/Browser
stanza.@from = u@gmail.com/SamePlace
stanza.body = u send this in SPS

Some trials/errors when trying to get xmlns value:
errors (displayed on alert() boxes);
======================================================================
stanza.x.namespace() = cannot call namespace method on an XML list with 0 elements (in Firebug)
stanza.x.namespace = blank (in Alert())
stanza.composing.namespace() = cannot call namespace method on an XML list with 0 elements (in Firebug)
stanza.composing.namespace = blank (in Alert())
stanza.x[0].namespace() = stanza.x[0] has no properties (in Firebug)
stanza.x[0].namespace = stanza.x[0] has no properties (in Firebug)
ToString(stanza.x) = ToString is not a function (in Firebug)
toString(stanza.x) = [object Window] (in Alert())
toString(stanza.x.namespace()) = cannot call namespace method on an XML list with 0 elements (in Firebug)
toString(stanza.x.namespace) = [object Window] (in Alert())
stanza.namespace('x') = "undefined" (in Alert())
stanza.namespace("x") = "undefined" (in Alert())
stanza.namespace("composing") = "undefined" (in Alert())
stanza.namespace() = blank (in Alert())

The syntax are based on E4X Spresification. Documentation are vague for now, but these are the 2 references that I think the most adequate.
http://www.ecma-international.org/publications/standards/Ecma-357.htm
http://livedocs.adobe.com/flex/201/html/wwhelp/wwhimpl/js/html/wwhelp.htm?href=13_Working_with_XML_169_01.html
--------------------------------------------------------------------------------
Stick to this schema. Owh and don't forget, you'll need 2 divs/container at all time. 1 with id="xmpp-incoming" and the other with id="xmpp-outgoing". Both are responsible to catch xmpp packet generated by xmpp4moz.

Here's a screeny to sum it up:












Demo app.

- solution: change codes to suit SPS's schema.
- incoming : DONE.
- outgoing : DONE.

- ERROR: SPS send an event on first keypress on SPS left panel. I can't seem to differentiate it from other messages.










Can't seem to differentiate this message with other REAL message, as result, blank messages may appear on chatroom. Posted this on the forum