This is a pre-release Gradient 1.1, which is a refactored & upgraded version of Gradient 1.0.
The previous version is described, documented, etc. on the old website. A lot of the information on that site is no longer accurate for v1.1, in particular all of the JavaDocs, most of the design notes, and anything that describes document loading is no longer accurate for 1.1.
The 1.1.0 final release will be accompanied by updated documentation.
22 December 2004: Here are some screenshots.
The client (approx 7 MB) contains the client. (1.4-series or greater J2RE/J2SDK required).
The library build, (approx 8 MB) contains the javadocs, library, and dependencies (1.4-series or greater J2RE/J2SDK required).
The server demonstration webapp, (approx 1 MB) contains a WAR file for deployment on a 2.3-series Java Servlet container, such as Tomcat 5.5. Some configuration required, see the old documentation (ignore points two and three) on how to modify web.xml with Jabber usernames & passwords, and web.xml itself for locations the usernames should be put in the SVG files.
The source distribution, (approx 7.5 MB) contains the required libraries, source code, resources and build files necessary to produce the above files.
When the document loads, we check for a "link" element in the Gradient namespace. If this element exists and has in a JID attribute a valid Jabber ID (JID) on an XMPP network that we can connect to, then this JID assumed to be the document controller, and is sent a message containing a generated thread ID (which acts as a shared secret between the server and the client) and the URL from which the document was loaded.
The ECMAScript DOM scripting environment of the SVG environment has been changed in two ways. Firstly, several XMPP-related events can be caught within the document ECMAscript by declaring functions with certain names. Secondly, several XMPP-related methods have been added that allow scripts to send information over XMPP networks.
XMPP events are triggered within ECMAScript when XMPP packets (stanzas) arrive via an XMPP network that are routable to this document, i.e. if:
The events can be broken down into to types, controller and everyone else. Controller methods are triggered only by stanzas originating from the controller. The other methods are triggered by anyone else.
connected(jid)
Fired when the document is connected to the XMPP network. This does not necessarily happen onload, since the user may not be connected at the time, and may choose not to connect to an XMPP network.
processMessage(elements, type)
elements: an Array containing the elements that make up the child elements of the <message> stanza.type: one of "normal", chat, error, etc. see RFC3921 (section 2.1.1) for a list of possible message types.processPresence(elements, type)
elements: an Array containing the elements that make up the child elements of the <presence> stanza.type: one of "available", etc. see RFC3921 (section 2.2.1) for a list of possible presence types.processIQ(element, type)
Unlike processMessage and processPresence, processIQ is only triggered explicitly if this document is referred to by it's thread ID, i.e. it's impossible for IQ requests to be routable to multiple documents.
element: the child element of the IQ (IQ's may only have one child element).type: one of "get" or "set".This function, if declared, MUST return an element. IQ being the RPC-equivalent of XMPP, the browser needs to know what to send back to the controller. If no element is returned, then any IQ that is targeted a this document will have a 500 error returned.
processUntrustedMessage(from, elements, type)
from: the Jabber ID (JID) of the sender.elements: an Array containing the elements that make up the child elements of the <message> stanza.type: one of "normal", chat, error, etc. see RFC3921 (section 2.1.1) for a list of possible message types.processUntrustedPresence(from, elements, type)
from: the JID of the sender.elements: an Array containing the elements that make up the child elements of the <message> stanza.type: one of "available", etc. see RFC3921 (section 2.2.1) for a list of possible presence types.processUntrustedIQ(from, element, type)
Unlike processUntrustedMessage and processUntrustedPresence, processUntrustedIQ is only triggered explicitly if this document is referred to by it's thread ID, i.e. it's impossible for IQ requests to be routable to multiple documents.
from: the JID of the sender.element: the child element of the IQ (IQ's may only have one child element).type: one of "get" or "set".This function, if declared, MUST return an element. IQ being the RPC-equivalent of XMPP, the browser needs to know what to send back to the sender. If no element is returned, then any IQ that is targeted a this document will have a 500 error returned.
The XMPP functions of the Gradient extension to Squiggle are declared at the same level as alert() and prompt(), i.e. they are not declared or used on a per-document basis, but on a per-environment basis. Why? Allowing one document to send message stanzas as if from another document simply because it has a reference to it (e.g. opener) is a bad idea because it allows impersonation.
isConnected()
Returns true if connected to an XMPP server.
getDocJID()
Returns the Jabber ID that this document is using to connect to the XMPP network to which the controller JID is connected.
getDocThread()
Returns the document thread ID.
getControllerJID()
Returns the controller JID of this document.
sendMessage(elements, [type, [to, [thread]]]);
Sends a message from the document JID.
elements: an Array containing the elements making up the children of the message stanza.type: defaults to "normal". one of chat, message, etc. see RFC3921 s.2.1.1.to: defaults to the controller JID. The Jabber ID to send the message to.thread: the thread ID to send the message to. If to is absent, defaults to the thread ID of document, otherwise none specified. If an element with default namespace and tag name "thread" is specified in elements, then this overwrites that element.sendIQ(element, [type, [to, [thread]]]);
element: the element of the child of the IQ stanza.type: defaults to "get". One of "get" or "set".to: defaults to the controller JID. The Jabber ID to send the message to.thread: the thread ID to send the IQ to. If to is absent, defaults to the thread ID of the document, none otherwise. The XMPP RFC does not ordinarily allow for threads on IQ's. The thread ID is specified using a "thread" attribute with the gradient namespace on the child element of the IQ stanza, where it's legal to extend XMPP.Perfection is the enemy of completion... - Or, "Why this is only a pre-release".