Jump to: navigation, search

Difference between revisions of "RAP/Protocol"

< RAP
m
(Changed grammar notation)
Line 18: Line 18:
  
 
=== Message ===  
 
=== Message ===  
<source lang="javascript">  
+
 
 +
There has to be exactly one message per request and one per response. (May differ while in development.)
 +
 
 +
<source lang="javascript">
 
{
 
{
   "meta" : Object MetaObject,
+
   "meta" : Meta,
   "operations" : Object[] OperationObject
+
   "operations" : [ Operation* ]
 
}
 
}
 
</source>
 
</source>
  
There has to be exactly one message per request and one per response. (May differ while in development.)
+
=== Meta ===
  
=== MetaObject ===
 
 
<source lang="javascript">
 
<source lang="javascript">
{  
+
{
   "requestCounter" : int counter
+
   "requestCounter" : <integer number>
 
}
 
}
 
</source>
 
</source>
  
=== OperationObject ===
+
=== Operation ===
 +
 
 +
One of the following types:
 +
<source lang="javascript">
 +
  CreateOperation | SetOperation | DestroyOperation | CallOperation | ListenOperation | ExecuteScriptOperation
 +
</source>
  
The operations are processed in the order that they are given in the message. Unkown operations will be ignored.
+
Operations are processed in the order of their appearance in the message. Unkown operations will be ignored.
  
==== Action Create ====
+
==== CreateOperation ====
  
 
<source lang="javascript">
 
<source lang="javascript">
 
{  
 
{  
 
   "action" : "create",
 
   "action" : "create",
   "target" : String targetId,
+
   "target" : <target id as string>,
 
   "type" : String rwt-type,
 
   "type" : String rwt-type,
   "properties" : Object properties
+
   "properties" : CreateProperties
 
}
 
}
 
</source>
 
</source>
  
==== Action Set ====
+
==== SetOperation ====
  
 
<source lang="javascript">
 
<source lang="javascript">
 
{  
 
{  
 
   "action" : "set",
 
   "action" : "set",
   "target" : String targetId,
+
   "target" : <target id as string>,
   "properties" : Object properties
+
   "properties" : SetProperties
 
}
 
}
 
</source>
 
</source>
  
==== Action Destroy ====
+
==== DestroyOperation ====
  
 
<source lang="javascript">
 
<source lang="javascript">
 
{  
 
{  
 
   "action" : "destroy",
 
   "action" : "destroy",
   "target" : String targetId
+
   "target" : <target id as string>
 
}
 
}
 
</source>
 
</source>
  
==== Action Call ====
+
==== CallOperation ====
  
 
<source lang="javascript">
 
<source lang="javascript">
 
{  
 
{  
 
   "action" : "call",
 
   "action" : "call",
   "target" : String targetId,
+
   "target" : <target id as string>,
   "method" : String methodName
+
   "method" : <method name as string>,
   "properties" : Object properties
+
   "properties" : CallProperties
 
}
 
}
 
</source>
 
</source>
  
==== Action Listen ====
+
==== ListenOperation ====
  
 
<source lang="javascript">
 
<source lang="javascript">
 
{  
 
{  
 
   "action" : "listen",
 
   "action" : "listen",
   "target" : String targetId,
+
   "target" : <target id as string>,
   "properties" : Object properties
+
   "properties" : ListenProperties
 
}
 
}
 
</source>
 
</source>
  
==== Action ExecuteScript ====
+
==== ExecuteScriptOperation ====
  
 
<source lang="javascript">
 
<source lang="javascript">
 
{  
 
{  
 
   "action" : "executeScript",
 
   "action" : "executeScript",
   "target" : String targetId,
+
   "target" : <target id as string>,
   "scriptType" : String scriptType
+
   "scriptType" : <script type as string>
   "content" : String script
+
   "content" : <script code as string>
 
}
 
}
 
</source>
 
</source>

Revision as of 10:08, 16 December 2011

Introduction

NOTE: All information within this document is subject to change until further notice.

The RAP Protocol is the JSON-based format used within the HTTP-Requests from a RAP-client to a RAP-server. Compared with the previously used JavaScript and HTTP-fields based communication it will provide a number of advantages:

  • It allowes to move all client-specific code from the server to the client.
  • It produces human readable messages, easing debugging.
  • It allowes the client to create more informative error messages.
  • It allowes to replace either ends as long as they process and create valid RAP-protocol messages.
  • It allowes to add client-independent client-side scripting.

The protocol is currently beeing developed in CVS HEAD. Server-to-Client communication is completed for all RWT-Widgets and will be part of the 1.5 release. Client-to-Server communication will possibly be implemented after 1.5.

Protocol Format

The protocol is based on the JSON fromat as described here: [ http://www.json.org/ ]

Message

There has to be exactly one message per request and one per response. (May differ while in development.)

{
  "meta" : Meta,
  "operations" : [ Operation* ]
}

Meta

{
  "requestCounter" : <integer number>
}

Operation

One of the following types:

  CreateOperation | SetOperation | DestroyOperation | CallOperation | ListenOperation | ExecuteScriptOperation

Operations are processed in the order of their appearance in the message. Unkown operations will be ignored.

CreateOperation

{ 
  "action" : "create",
  "target" : <target id as string>,
  "type" : String rwt-type,
  "properties" : CreateProperties
}

SetOperation

{ 
  "action" : "set",
  "target" : <target id as string>,
  "properties" : SetProperties
}

DestroyOperation

{ 
  "action" : "destroy",
  "target" : <target id as string>
}

CallOperation

{ 
  "action" : "call",
  "target" : <target id as string>,
  "method" : <method name as string>,
  "properties" : CallProperties
}

ListenOperation

{ 
  "action" : "listen",
  "target" : <target id as string>,
  "properties" : ListenProperties
}

ExecuteScriptOperation

{ 
  "action" : "executeScript",
  "target" : <target id as string>,
  "scriptType" : <script type as string>
  "content" : <script code as string>
}

Data Type Reference

In addition to the datatypes recognized by JSON itself, the RAP protocol also uses these composed types:

Bounds

[ int left, int top, int witdh, int height ]

Note that left and top may be negative. No value may be null.

Color

[ int red, int green, int blue, int alpha ]

All values are to be between 0 and 255. The alpha value may be ignored by the client unless its 0.

Image

[ String url, int width, int height ] | null

Gradient

[ Color[] colors, int[] stops, boolean verticalFlag ] | null

The number of colors must match the number of stops. Each stop is a value between 0 and 1, and has to be equal or higher then the previous stop.

Object Type Reference

Server and JavaScript-Client API