Given by TangoInteractive Team at Tango Tutorial Alliance 98 NCSA Illinois on April 27 98. Foils prepared April 25 98
Outside Index
Summary of Material
Java basic API |
JavaScript API |
Java Object API |
C API |
Outside Index Summary of Material
Presented by Geoffrey Fox, Marek Podgorny and TANGO team |
NPAC, Syracuse University |
Alliance `98, April 27th, `98 |
Java basic API |
JavaScript API |
Java Object API |
C API |
Basic functionality - sending and receiving data |
application calling `send' method puts some information into the system |
information is carried to all the applications connected to the same session |
when a message arrives the `receive' method is called on the destination application |
public void register()
|
public void send (AppEventMessage m)
|
public abstract void receive (AppEventMessage m)
|
AppEventMessage can contain two types of messsges: |
DATA - information sent between applications in one session |
examples : a string representing sentence in chat |
a list of x,y coordinates describing a figure in paint |
CONTROL - system-specific information exchanged between application and Control Application; e.g. request for list of users or floor control information |
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 applications on the same host |
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) { // checking for message type |
CAppAnswerEventMessage msg = (CAppAnswerEventMessage) em; |
//The above is conversion to control message |
if (msg.getAnswerType() == CAConsts.USERNAME) |
un = msg.getUserName(); //extraction of information |
} |
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()]; //creation of 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); |
} |
Object API - allows more complex operations (e.g. automatic update of state) for Java applets |
C API - used for standalone applications; based on socket connection |
JavaScript API - similar to Java, messages in form of strings |
For simple JavaScript applications:
|
For integration applications:
|
Object API to Tango allows direct communication between corresponding client objects. |
Simplifies design and implementation |
Provides automatic distribution of initial state |
All communication logic for an object is located with that object which improves maintainability |
O2 |
O1 |
O1 |
O2 |
Client1 |
Client2 |
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. |
Http://dagger/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. |
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 )
|
Receiving messages
|
Sending messages
|