Full HTML for

Basic foilset General Tango API Java JavaScript and C

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

Table of Contents for full HTML of General Tango API Java JavaScript and C

Denote Foils where Image Critical
Denote Foils where Image has important information
Denote Foils where HTML is sufficient

1 TANGO Interactive Tutorial Overview of Tango API
2 Tango APIs - outline
3 Tango API - Overview
4 Tango event distribution model
5 Tango API for applets
6 Tango API - AppEventMessage
7 Tango API Control types
8 Java API - code example
9 Java API - code example ctd.
10 Java API - code example ctd.
11 Other Tango APIs
12 JavaScript interface to Tango
13 Java Object API
14 Java Object API - description
15 Java Object API -example
16 TANGO API for C Applications
17 Registering an Application in C API
18 TANGO Message in C API
19 TANGO Message (cont.)
20 TANGO Message (cont.)
21 Sending and Receiving Messages in C

Outside Index Summary of Material



HTML version of Basic Foils prepared April 25 98

Foil 1 TANGO Interactive Tutorial Overview of Tango API

From General Tango API Java JavaScript and C Tango Tutorial Alliance 98 NCSA Illinois -- April 27 98. *
Full HTML Index
Presented by Geoffrey Fox, Marek Podgorny and TANGO team
NPAC, Syracuse University
Alliance `98, April 27th, `98

HTML version of Basic Foils prepared April 25 98

Foil 2 Tango APIs - outline

From General Tango API Java JavaScript and C Tango Tutorial Alliance 98 NCSA Illinois -- April 27 98. *
Full HTML Index
Java basic API
JavaScript API
Java Object API
C API

HTML version of Basic Foils prepared April 25 98

Foil 3 Tango API - Overview

From General Tango API Java JavaScript and C Tango Tutorial Alliance 98 NCSA Illinois -- April 27 98. *
Full HTML Index
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

HTML version of Basic Foils prepared April 25 98

Foil 4 Tango event distribution model

From General Tango API Java JavaScript and C Tango Tutorial Alliance 98 NCSA Illinois -- April 27 98. *
Full HTML Index

HTML version of Basic Foils prepared April 25 98

Foil 5 Tango API for applets

From General Tango API Java JavaScript and C Tango Tutorial Alliance 98 NCSA Illinois -- April 27 98. *
Full HTML Index
public void register()
  • connects application with the rest of the system; this method should be called during the program startup
public void send (AppEventMessage m)
  • sends information wrapped in a AppEventMessage class through Tango system
public abstract void receive (AppEventMessage m)
  • callback method called each time a new message arrives; it's implementation is application dependent and has to contain application-specific code for event handling

HTML version of Basic Foils prepared April 25 98

Foil 6 Tango API - AppEventMessage

From General Tango API Java JavaScript and C Tango Tutorial Alliance 98 NCSA Illinois -- April 27 98. *
Full HTML Index
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

HTML version of Basic Foils prepared April 25 98

Foil 7 Tango API Control types

From General Tango API Java JavaScript and C Tango Tutorial Alliance 98 NCSA Illinois -- April 27 98. *
Full HTML Index
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

HTML version of Basic Foils prepared April 25 98

Foil 8 Java API - code example

From General Tango API Java JavaScript and C Tango Tutorial Alliance 98 NCSA Illinois -- April 27 98. *
Full HTML Index
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
}

HTML version of Basic Foils prepared April 25 98

Foil 9 Java API - code example ctd.

From General Tango API Java JavaScript and C Tango Tutorial Alliance 98 NCSA Illinois -- April 27 98. *
Full HTML Index
// 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);
}
}

HTML version of Basic Foils prepared April 25 98

Foil 10 Java API - code example ctd.

From General Tango API Java JavaScript and C Tango Tutorial Alliance 98 NCSA Illinois -- April 27 98. *
Full HTML Index
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);
}

HTML version of Basic Foils prepared April 25 98

Foil 11 Other Tango APIs

From General Tango API Java JavaScript and C Tango Tutorial Alliance 98 NCSA Illinois -- April 27 98. *
Full HTML Index
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

HTML version of Basic Foils prepared April 25 98

Foil 12 JavaScript interface to Tango

From General Tango API Java JavaScript and C Tango Tutorial Alliance 98 NCSA Illinois -- April 27 98. *
Full HTML Index
For simple JavaScript applications:
  • send( String ) / receive( String )
For integration applications:
  • multiple Java applets and JavaScript functions on one HTML page and in one Tango session
  • JavaScript code used as a convenient integration environment
  • named channels for different applications
  • arbitrary messages exchanged between Java applets (fast/scripted assembly of customized applications)
  • String messages used for functions handled directly by JavaScript:
  • sendString( channel, String ) / receiveString( channel, String )
  • opaque byte arrays used for communicating applets:
  • sendBytes( channel, byte[ ] ) / receiveBytes( channel, byte[ ] )

HTML version of Basic Foils prepared April 25 98

Foil 13 Java Object API

From General Tango API Java JavaScript and C Tango Tutorial Alliance 98 NCSA Illinois -- April 27 98. *
Full HTML Index
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

HTML version of Basic Foils prepared April 25 98

Foil 14 Java Object API - description

From General Tango API Java JavaScript and C Tango Tutorial Alliance 98 NCSA Illinois -- April 27 98. *
Full HTML Index
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
  • registering TObjects
  • building messages
  • accessing general Tango related information (information about users, sessions, etc.)
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.

HTML version of Basic Foils prepared April 25 98

Foil 15 Java Object API -example

From General Tango API Java JavaScript and C Tango Tutorial Alliance 98 NCSA Illinois -- April 27 98. *
Full HTML Index
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.

HTML version of Basic Foils prepared April 25 98

Foil 16 TANGO API for C Applications

From General Tango API Java JavaScript and C Tango Tutorial Alliance 98 NCSA Illinois -- April 27 98. *
Full HTML Index
Based on socket connections
Provides methods for:
  • registering an application
  • receiving messages from TANGO or other apps
  • sending messages to TANGO or other apps
  • creating/destroying/managing messages

HTML version of Basic Foils prepared April 25 98

Foil 17 Registering an Application in C API

From General Tango API Java JavaScript and C Tango Tutorial Alliance 98 NCSA Illinois -- April 27 98. *
Full HTML Index
Registering an application that uses C runtime library
  • SOCKET registerApp( int argc, char* argv[] )
    • takes program parameters as provided in main(...)
    • returns socket connected to TANGO or INVALID_SOCKET
Registering Win32 application
  • SOCKET registerWinApp( LPSTR lpCmdLine )
    • takes program parameters as provided in WinMain(...)
    • returns socket connected to TANGO or INVALID_SOCKET

HTML version of Basic Foils prepared April 25 98

Foil 18 TANGO Message in C API

From General Tango API Java JavaScript and C Tango Tutorial Alliance 98 NCSA Illinois -- April 27 98. *
Full HTML Index
Attributes
  • type
    • CONTROL: send to Control Application
    • DATA: send to other participating applications
  • len: length of data field
  • data: pointer to actual data
Creation created using createEvent method
  • struct Event* createEvent( int type, int len, char* data )

HTML version of Basic Foils prepared April 25 98

Foil 19 TANGO Message (cont.)

From General Tango API Java JavaScript and C Tango Tutorial Alliance 98 NCSA Illinois -- April 27 98. *
Full HTML Index
Destruction
  • to prevent memory leaks, suggested method of deallocating a message is by using destroyEvent method
  • void destroyEvent( struct Event* )
    • it takes care of data field deallocation
    • uses appropriate destructor

HTML version of Basic Foils prepared April 25 98

Foil 20 TANGO Message (cont.)

From General Tango API Java JavaScript and C Tango Tutorial Alliance 98 NCSA Illinois -- April 27 98. *
Full HTML Index
int getType( struct Event* pEv )
  • returns type of message (DATA or CONTROL)
int getLen( struct Event* pEv )
  • returns length of data
char* getData( struct Event* pEv )
  • returns pointer to data
  • returned pointer points to newly allocated buffer, this buffer should be freed using C free(...) function

HTML version of Basic Foils prepared April 25 98

Foil 21 Sending and Receiving Messages in C

From General Tango API Java JavaScript and C Tango Tutorial Alliance 98 NCSA Illinois -- April 27 98. *
Full HTML Index
Receiving messages
  • struct Event* receiveEvent( SOCKET s)
    • s - socket to receive a message from
    • returns pointer to received message or NULL
    • if there is no available data, method blocks
Sending messages
  • HRESULT sendEvent( SOCKET s, struct Event* pEv )
    • s - socket to send a message to
    • pEv - message to be sent

© Northeast Parallel Architectures Center, Syracuse University, npac@npac.syr.edu

If you have any comments about this server, send e-mail to webmaster@npac.syr.edu.

Page produced by wwwfoil on Sun May 3 1998