Contents | Index | Previous | Next

Appendix A: Using "Fake Tango"

JavaScript applications written for Tango can be tested without the Tango session manager. Instead, a "fake server" must be running and the script must use a different registration method.

The "fake server" can be started by issuing the following command from the operating system shell (should it be UNIX or PC):

$ java webwisdom.tango.fake.TServerFake 32831

The above command starts Java virtual machine and executes TServerFake class. Java virtual machine must be installed and the CLASSPATH environment variable has to include tango.jar archive. The command starts the "fake server" that listens on the port given in the parameter (32831).

Once the "fake server" is running, JavaScript applications can connect to it as if they connected to the session manager. The only difference is that a different registration procedure must be called. The code below highlights the dissimilarity, otherwise is identical to the example 2.1.

exA1.html

<html>

<body onUnload="Tango_exit()">

<script language="javascript">

function Tango_register(win)

{

Tango_agent=Packages.webwisdom.tango.\

TAgentJS.createTAgentFakeJS("kopernik.npac.syr.edu",32831);

}

function Tango_exit()

{

if(Tango_agent!=null)

Tango_agent.exitJS();

}

function Tango_send(m)

{

if(Tango_agent!=null)

Tango_agent.sendJS(m);

}

function Tango_receive(m)

{

document.forms.chat.tty.value=m;

}

Tango_register(window);

if(Tango_agent!=null)

Tango_agent.addTDataListenerJS(window);

</script>

<form name="chat">

<input type="text" name="tty" size=16 onclick="Tango_send(tty.value)">

<input type="button" value="send">

</form>

</body>

</html>

In the script above Tango_agent is created by the method createTAgentFakeJS() instead of createTAgentJS(). The method takes two parameters: the host name, and the port number of the "fake server". If, for whatever reason, registration fails, null is returned.

For the obvious reason of missing control application, the "fake" setup cannot implement the full functionality of the real Tango. Only a pair Tango_agent.send() and Tango_receive() can be reliably used, while all control interfaces has no guaranteed modus operandi.