Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "RAP/Protocol"

< RAP
(updated introduction)
(added basic operations reference)
Line 20: Line 20:
 
<source lang="javascript">  
 
<source lang="javascript">  
 
{
 
{
   "meta" : MetaObject,
+
   "meta" : Object MetaObject,
   "operations" : [ (OperationObject)* ]
+
   "operations" : [ (Object OperationObject)* ]
 
}
 
}
 
</source>
 
</source>
Line 30: Line 30:
 
<source lang="javascript">
 
<source lang="javascript">
 
{  
 
{  
   "requestCounter" : int
+
   "requestCounter" : int counter
 
}
 
}
 
</source>
 
</source>
  
 
=== OperationObject ===
 
=== OperationObject ===
+
 
TODO
+
The operations are processed in the order that they are given in the message. Unkown operations will be ignored.
 +
 
 +
==== Action Create ====
 +
 
 +
<source lang="javascript">
 +
{
 +
  "action" : "create",
 +
  "target" : String targetId,
 +
  "type" : String rwt-type,
 +
  "properties" : Object properties
 +
}
 +
</source>
 +
 
 +
==== Action Set ====
 +
 
 +
<source lang="javascript">
 +
{
 +
  "action" : "set",
 +
  "target" : String targetId,
 +
  "properties" : Object properties
 +
}
 +
</source>
 +
 
 +
==== Action Destroy ====
 +
 
 +
<source lang="javascript">
 +
{
 +
  "action" : "destroy",
 +
  "target" : String targetId
 +
}
 +
</source>
 +
 
 +
==== Action Call ====
 +
 
 +
<source lang="javascript">
 +
{
 +
  "action" : "call",
 +
  "target" : String targetId,
 +
  "method" : String methodName
 +
  "properties" : Object properties
 +
}
 +
</source>
 +
 
 +
==== Action Listen ====
 +
 
 +
<source lang="javascript">
 +
{
 +
  "action" : "listen",
 +
  "target" : String targetId,
 +
  "properties" : Object properties
 +
}
 +
</source>
 +
 
 +
==== Action ExecuteScript ====
 +
 
 +
<source lang="javascript">
 +
{
 +
  "action" : "executeScript",
 +
  "target" : String targetId,
 +
  "scriptType" : String scriptType
 +
  "content" : String script
 +
}
 +
</source>
 +
 
  
 
== Data Type Reference ==
 
== Data Type Reference ==

Revision as of 11:12, 15 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

 
{
  "meta" : Object MetaObject,
  "operations" : [ (Object OperationObject)* ]
}

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

MetaObject

{ 
  "requestCounter" : int counter
}

OperationObject

The operations are processed in the order that they are given in the message. Unkown operations will be ignored.

Action Create

{ 
  "action" : "create",
  "target" : String targetId,
  "type" : String rwt-type,
  "properties" : Object properties
}

Action Set

{ 
  "action" : "set",
  "target" : String targetId,
  "properties" : Object properties
}

Action Destroy

{ 
  "action" : "destroy",
  "target" : String targetId
}

Action Call

{ 
  "action" : "call",
  "target" : String targetId,
  "method" : String methodName
  "properties" : Object properties
}

Action Listen

{ 
  "action" : "listen",
  "target" : String targetId,
  "properties" : Object properties
}

Action ExecuteScript

{ 
  "action" : "executeScript",
  "target" : String targetId,
  "scriptType" : String scriptType
  "content" : String script
}


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

Width and height are mandatory. If there is no image the entire value has to be null.

Object Type Reference

Server and JavaScript-Client API

Back to the top