Client-side API

Classes

DataQuery

DataQuery is basically a simple wrapper around a XMLHttpRequest, that handles URL structure, error handling and caching transparently.

Constructor

Exceptions

Example

 var q = new DataQuery ("mail", [[Documentation/Crystal/SessionInfo|session]], { mailbox: "INBOX" };
 q.dataComplete = function (msg) { alert (msg); };
 q.dataFailure = function (code, msg) { alert ("Error occured: (" + code + "): " + msg); };
 q.run (); // run worker async

HandshakeRequest

HandshakeRequest manages and initialises a new remote session via the [[Documentation/Crystal/SessionInfo|SessionInfo]] object.

Constructor

new HandshakeRequest (user, handler, [password])
Name Type Required Description
user String Yes Username, email or similar field used to pass to the authentication provider.
handler String Yes Authentication provider on the server to use. Examples include 'store', 'openid', and so on.
Password String No Either plain-text or hashed password to be passed to the authentication provider along with the username. Not required by all authentication providers.

Properties

authSuccessful

'''Type:''' Function
'''Default:''' null

Function to run when the handshake has completed and run without fail. The function will be run with a single argument, the [[Documentation/Crystal/SessionInfo|SessionInfo]] object for the newly created session.

authFailure

'''Type:''' Function
'''Default:''' null

FFunction to be run when the handshake failed on the server. This is generally ''not'' a web exception; use the requestFailure property for that purpose. This function will be called with two arguments, the error code, followed by the error message (en_US only). Please base internationalisable error messages off the error code, rather than the message returned; it should only be used for debugging/testing.

requestFailure

'''Type:''' Function
'''Default:''' null

FFunction to be run when the data query encounters an error. This can be assumed to be a web-related exception. The function will be called with the same arguments as run by MooTools's Request onFailure event. See http://docs12b.mootools.net/Request/Request#Request:events for more information.

Methods

run ()

'''Returns:''' nothing

FRuns the current HandshakeRequest instance asynchronously. Calls authComplete when the user has been successfully authenticated and a new session created, and authFailure if there was an authentication error.

Example

var a = new HandshakeRequest ("rupert", "store", "mypassword"); a.authSuccessful = onAuthComplete; a.run ();

Data types

SessionInfo

TODO

Properties

user

'''Type:''' String
'''Default:''' null Username associated with session.

uid

'''Type:''' Integer
'''Default:''' -1 Current session ID.

authprovider

'''Type:''' String
'''Default:''' null Authentication provider name associated with this session instance.

cache

'''Type:''' [[Documentation/Crystal/Cache|Cache]]
'''Default:''' null Current cache instance.

Methods

close ()

'''Returns:''' Boolean Does nothing for the moment. :)

Example

TODO!

Data Transport

TODO.

Server-side API

See Avocado for more information.