Service Broker
The Appcelerator Service Broker routes services and marshalls data to your service handlers. Each Appcelerator server backend (Java, PHP, Rails, etc) has a service broker that consumes messages from the client and allows your backend to send a response.
The messaging protocol is lightweight, making it very simple for you to write your own custom service broker for handling client-side messages (e.g. to support a backend that we have not yet implemented).
Protocol Details
The client defaults to a JSON protocol using HTTP POST to send messages to the server. If you wish to use XML-wrapped JSON, see the Advanced Configuration section on how to switch the marshaller.
A great way to see this in action is to use Firebug on the servicetester.html page in your project.
Request
version: the version of the Appcelerator protocol
time: the timestamp of this request in milliseconds since the Unix epoch (GMT)
sessionid: (optional) the session id of the current session
messages: (an array of objects conforming to the message schema below)
{"timestamp": 1214008045871, "version": "1.0",
"messages": [{"type": "app.test.message.request", "scope": "appcelerator",
"version": "1.0", "data": {"message": "Hello,world"}}]}
Response
version: the version of the Appcelerator protocol
time: the timestamp of this response in milliseconds since the Unix epoch (GMT)
sessionid: (optional) the session id of the current session
messages: (an array of objects conforming to the message schema below)
{"timestamp": 1214008045871, "version": "1.0",
"messages": [{"type": "app.test.message.response", "scope": "appcelerator",
"version": "1.0", "data": {"message": "I received from you: Hello,world",
"success":true}}]}
Message
type: the message type
version: the version of the service to access
scope: the scope of this message (required to echo the same value back in response)
data: a JSON object containing the data payload
{"version": "1.0", "scope":"appcelerator", "type":"app.test.message.response",
"data":{"message":"I received from you: Hello,world","success":true}}