Given by TangoInteractive Team at Tango Tutorial San Diego MRA on June 26 27 98 Datemod;June 26 98. Foils prepared
Outside Index
Summary of Material
Java basic API |
JavaScript API |
Java Object API |
C/C++ API |
Channel Interface for linking compund applications |
TANGOBean Interface described separately |
Outside Index Summary of Material
Prepared by Marek Podgorny and TANGO Team |
Presented by Geoffrey Fox |
NPAC, Syracuse University |
MRA Meeting June 26-27 1998 |
Java basic API |
JavaScript API |
Java Object API |
C/C++ API |
Channel Interface for linking compund applications |
TANGOBean Interface described separately |
TANGO has an API which is differentiated by language, level of user interface and by functionality |
At the highest level, a "TANGOBean" uses JavaBean technology to automate sharing of events with details hidden from user
|
At the lowest level (at which we start), there is a basic message passing interface for Java, JavaScript, C/C++ and LISP
|
At an intermediate level, the Object Interface hides the object serialization needed to get a byte stream from the user (Java and C++) |
Finally there is a special Channel Interface for establishing specialized linkages between groups of related shared applications
|
All APIs are build hierarchically, with message-passing API as root |
Basic functionality - sending and receiving data |
Application calling `send' method puts some information into the system |
Information is carried via the TANGO Server to all the applications connected to the same session |
When a message arrives the `receive' method is invoked on the destination application |
Message distribution is handled automatically and transparently |
public void register()
|
public void send (AppEventMessage m)
|
public abstract void receive (AppEventMessage m)
|
AppEventMessage can contain two types of messages: |
DATA - information sent between applications in one session
|
CONTROL - system-specific information exchanged between application and Control Application
|
ISMASTER - request for master/slave status |
USERNAME - request for user name |
MASTERNAME- request for the name of master |
HOSTNAME - request for hostname |
PARTICIPANTS - request for list of participants in the current session |
ACTIVEUSERS - request for list of users logged into the system |
LOCALAPPS - request for the list of applications |
DATAPASS - request for data transfer between different applications on the same host |
Let us Construct a Simple Chat application in Java |
create any Java class which extends TANGOApplet
|
Now we must add as explained on next foil Collaboratory function for this applet and register it in a TANGO Control Application |
First add collaboratory functionality to the previous class
|
Embed the applet in an HTML page
|
Register the page in a TANGO Control Application |
import messages.*; //TANGO Packages |
import interfaces.AppletBase; |
import consts.*; |
Public class Chat extends AppletBase{//TANGO base class |
public void init() { |
setLayout(new BorderLayout()); //GUI setup |
add("Center",ta=new TextArea()); |
add("South",tf=new TextField()); |
register(); //TANGO API call |
byte[] t=new byte[1]; |
t[0] = CAConsts.USERNAME; //creation of TANGO control message |
AppEventMessage em=new AppEventMessage |
(Const.CONTROL,t); |
send(em); //TANGO API call |
} |
// TANGO api `receive' implementation |
public void receive (AppEventMessage em) { |
if (em.getType() == Const.CONTROL) {//check message type |
CAppAnswerEventMessage msg = (CAppAnswerEventMessage) em; |
//The above is conversion to control message |
if (msg.getAnswerType() == CAConsts.USERNAME) |
un = msg.getUserName(); //extraction of data |
} else { //DATA type message |
String msg=new String |
(em.getData(),0,0,em.getLen()); //extraction of data |
ta.appendText(msg); |
} |
} |
public boolean action(Event e,Object o) { |
if (o instanceof TextField) { |
String msg=un+" : "+tf.getText(); |
byte[] t=new byte[msg.length()];//create byte table |
msg.getBytes(0,msg.length(),t,0);//string to byte[]conversion |
AppEventMessage em=new AppEventMessage(Const.DATA,t); |
// The above is a new message |
send(em); //TANGO API call |
tf.setText(""); |
return true; |
} |
else |
return super.action(e,o); |
} |
C API - used for standalone applications; based on socket connection
|
C++ API - encapsulates C API in a set of classes |
JavaScript API - similar to Java, messages in form of strings
|
Object API - allows more complex operations (e.g. automatic update of state) for Java applets |
For simple JavaScript applications:
|
For compound applications:
|
Compound applications, continued:
|
Chat application in pure HTML illustrates a Shared Form |
Can use JavaScript 1.2 event routing mechanisms to automatically track changes in form entries |
Open tangoTemplate.html file for editing |
Add HTML content at will
|
Add collaboratory functionality
|
Register the application in a TANGO Control Application |
JS API is transparent (i.e. pages will work the same way with and w/o TANGO
|
O2 |
O1 |
O1 |
O2 |
Client1 |
Client2 |
Object API allows direct communication between corresponding client objects.
|
The API consists of the class TNode and an an interface Tobject |
Class TNode covers the standard TANGO API. It provides routing mechanisms for messages distributed in the system, so that they are passed only to corresponding TObject on other instances of the Applet |
TNode provides methods for
|
TObject interface defines methods called by the TNode when the object is created, a message for that TObject arrives or when the TObject should be discarded.
|
See Server Address/applets/APIExample/ |
The applet allows adding and moving icons. |
Each icon implements a TObject interface. |
When icon is added or moved on one instance of the applet the changes are automatically reflected on other instances |
When a new client joins the session it automatically receives the current state of the session. |
Receiving messages
|
Sending messages
|
Some applications use dynamically created objects which are essentially independent shared entities grouped together
|
Challenges:
|
Solution for TANGO applets:
|
Nota bene: TANGO per design does not use shared objects on the server
|
Implementation of the synchronization mechanism:
|
Synchronizer tasks:
|
Updatable tasks:
|
Based on socket connections |
Provides methods for:
|
Registering an application that uses C runtime library
|
Registering Win32 application
|
Attributes
|
Creation created using createEvent method
|
Destruction
|
int getType (struct Event* pEv)
|
int getLen (struct Event* pEv)
|
char* getData (struct Event* pEv)
|