import java.applet.Applet; import java.awt.Button; import java.awt.GridLayout; import java.awt.Label; import java.awt.TextField; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.net.MalformedURLException; import java.net.URL; import lava.net.common.UNA; import lava.net.common.UNL; import lava.net.mmp.MMPMessageCenter; import lava.net.psyc.PSYCMessageCenter; import lava.net.psyc.UNI; import lava.net.psyc.packages.Authentication; import lava.net.psyc.packages.Biff; import lava.net.psyc.packages.Echo; import lava.net.psyc.packages.Trace; import lava.net.psyc.packages.LinkPeer; import lava.net.psyc.packages.Statistics; /** * **/ public class PSYCBiffApplet extends Applet implements ActionListener { /** * **/ private String base = null; /** * **/ private UNA proxy = null; /** * **/ private TextField userProgram = null; /** * **/ public final static String userProgramTag = "User Program"; /** * **/ public final static String userProgramDefault = "psyc://"; /** * **/ private TextField password = null; /** * **/ public final static String passwordTag = "Password"; /** * **/ public final static String passwordDefault = null; /** * **/ public final static int width = 60; /** * **/ private Button start = null; /** * **/ public final static String startButton = "Start PSYCBiff"; /** * **/ private Button reset = null; /** * **/ public final static String resetButton = "Reset Entries"; /** * **/ public void init() { base = "http://141.24.32.50/~holbe/lava/"; String codeBase = getCodeBase().getHost(); if(codeBase == null || codeBase.length() <= 0) codeBase = "localhost"; UNA.addAppletHost(codeBase); PSYCMessageCenter.setDefaults(); proxy = new UNA(null,codeBase,MMPMessageCenter.defaultPort,// MMPMessageCenter.defaultProtocol,null); setLayout(new GridLayout(3,2)); add(new Label(userProgramTag,Label.RIGHT)); add(userProgram = new TextField(width)); userProgram.addActionListener(this); add(new Label(passwordTag,Label.RIGHT)); add(password = new TextField(width)); password.setEchoChar('*'); add(start = new Button(startButton)); start.addActionListener(this); add(reset = new Button(resetButton)); reset.addActionListener(this); setDefaults(); } /** * **/ private void setDefaults() { userProgram.setText(userProgramDefault); password.setText(passwordDefault); } /** * **/ public void actionPerformed(ActionEvent e) { Object source = e.getSource(); String command = e.getActionCommand(); if(source == userProgram) { UNL test = new UNL(command); userProgram.setText(test.toString()); } else if(source == start) { PSYCBiff biff = new PSYCBiff(base); biff.password = password.getText(); biff.center = new PSYCMessageCenter(null,false); System.out.println("proxy: " + proxy); ((MMPMessageCenter)biff.center.getMMPCenter()).setProxy(null,proxy); biff.center.setIdentification(null,// new UNI(userProgram.getText())); biff.center.setContentType(null,"text/plain"); biff.center.setGreeting("_notice_session_start",// "Hello.\n\nWelcome to the wonderful world of PSYC!"); biff.center.addPackage(biff.biff_backend = new Biff(biff)); biff.center.addPackage(biff.auth_backend = // new Authentication(biff)); System.out.println("connecting to " + // biff.center.getIdentification(null)); biff.center.addPackage(biff.user_backend = new LinkPeer(biff)); biff.center.addPackage(new Echo()); biff.center.addPackage(new Trace()); biff.center.addPackage(new Statistics()); } else if(source == reset) { setDefaults(); } } }