examples.chat
Class ChatAgent

java.lang.Object
  extended byexamples.chat.ChatAgent
All Implemented Interfaces:
ActionListener, EventListener, Resumable, Runnable, Serializable, WindowListener

public class ChatAgent
extends Object
implements Resumable, Serializable, ActionListener, WindowListener

This class is mobile code, which will migrate through the peer-network and enables user to exchange textmassages with each other.

Version:
"$Id: ChatAgent.java 1913 2007-08-08 02:41:53Z jpeters $"
Author:
Andreas Reuter
See Also:
Serialized Form

Field Summary
private  JTextArea convHist_
           
private  JTextField convInput_
           
private  LinkedList convList_
           
private  int convListIndex_
           
(package private) static boolean DEBUG
           
private  String dest_
           
private  JButton destButton_
           
private  JButton exitButton_
           
private  JButton goButton_
           
private  String home_
           
private  JFrame initFrame_
           
private  Object lock_
           
private  MobilityContext mob_
           
private  AgentCard myCard_
           
private  JComboBox serverChoiceBox_
           
private  String source_
           
private  JFrame talkFrame_
           
private  ArrayList urls_
           
 
Constructor Summary
ChatAgent()
          Creates an object of the class ChatAgent
 
Method Summary
 void actionPerformed(ActionEvent aEvent)
          Defines the specific action sequence of all buttons of this class
private  ArrayList findTargets()
          Get a list of all peers found in the VICINITY-network
private  void initGUI()
          Method enables the user to choose a chat-partner in the VICINITY-network
private  boolean isHome()
          Get a list of all peers found in the VICINITY-network
 void resume(ErrorCode err)
          After an agent was suspended on a peer, he will migrate to >null< and terminate.
 void run()
          This method will be executed after an agent has reached a peer.
private  void talkGUI()
          Method enables the user to create and read textmessages with th choosen chat-partner.
 void windowActivated(WindowEvent wEvent)
          Is not spezified in this program
 void windowClosed(WindowEvent wEvent)
          When window closed the agent will leave his locked state
 void windowClosing(WindowEvent wEvent)
          Dispose all windows and terminate agent
 void windowDeactivated(WindowEvent wEvent)
          Is not spezified in this program
 void windowDeiconified(WindowEvent wEvent)
          Is not spezified in this program
 void windowIconified(WindowEvent wEvent)
          Is not spezified in this program
 void windowOpened(WindowEvent wEvent)
          Is not spezified in this program
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEBUG

static final boolean DEBUG
See Also:
Constant Field Values

initFrame_

private transient JFrame initFrame_

talkFrame_

private transient JFrame talkFrame_

serverChoiceBox_

private transient JComboBox serverChoiceBox_

mob_

private transient MobilityContext mob_

destButton_

private transient JButton destButton_

goButton_

private transient JButton goButton_

exitButton_

private transient JButton exitButton_

convHist_

private transient JTextArea convHist_

convInput_

private transient JTextField convInput_

convList_

private LinkedList convList_

urls_

private ArrayList urls_

convListIndex_

private int convListIndex_

home_

private String home_

source_

private String source_

dest_

private String dest_

lock_

private Object lock_

myCard_

private AgentCard myCard_
Constructor Detail

ChatAgent

public ChatAgent()
Creates an object of the class ChatAgent

Method Detail

resume

public void resume(ErrorCode err)
After an agent was suspended on a peer, he will migrate to >null< and terminate.

Specified by:
resume in interface Resumable
Parameters:
err - ErrorCode Error, which is appeared during the program execution

run

public void run()
This method will be executed after an agent has reached a peer. The agents behaviour depends on some variable values

Specified by:
run in interface Runnable
Throws:
InterruptedException - Interrupts the wait-state of the agent

initGUI

private void initGUI()
Method enables the user to choose a chat-partner in the VICINITY-network


talkGUI

private void talkGUI()
Method enables the user to create and read textmessages with th choosen chat-partner.

Throws:
Exception - If a problem with the inet-addresses happens

actionPerformed

public void actionPerformed(ActionEvent aEvent)
Defines the specific action sequence of all buttons of this class

Specified by:
actionPerformed in interface ActionListener
Parameters:
aEvent - ActionEvent An event from one of the GUI components.
Throws:
Exception - If there are migration problems

windowClosed

public void windowClosed(WindowEvent wEvent)
When window closed the agent will leave his locked state

Specified by:
windowClosed in interface WindowListener
Parameters:
wEvent - WindowEvent An event from one of the windows.

windowClosing

public void windowClosing(WindowEvent wEvent)
Dispose all windows and terminate agent

Specified by:
windowClosing in interface WindowListener
Parameters:
wEvent - WindowEvent An event from one of the windows.

windowActivated

public void windowActivated(WindowEvent wEvent)
Is not spezified in this program

Specified by:
windowActivated in interface WindowListener
Parameters:
wEvent - WindowEvent An event from one of the windows.

windowDeactivated

public void windowDeactivated(WindowEvent wEvent)
Is not spezified in this program

Specified by:
windowDeactivated in interface WindowListener
Parameters:
wEvent - WindowEvent An event from one of the windows.

windowDeiconified

public void windowDeiconified(WindowEvent wEvent)
Is not spezified in this program

Specified by:
windowDeiconified in interface WindowListener
Parameters:
wEvent - WindowEvent An event from one of the windows.

windowIconified

public void windowIconified(WindowEvent wEvent)
Is not spezified in this program

Specified by:
windowIconified in interface WindowListener
Parameters:
wEvent - WindowEvent An event from one of the windows.

windowOpened

public void windowOpened(WindowEvent wEvent)
Is not spezified in this program

Specified by:
windowOpened in interface WindowListener
Parameters:
wEvent - WindowEvent An event from one of the windows.

isHome

private boolean isHome()
Get a list of all peers found in the VICINITY-network

Returns:
List of all peers which were found in the VICINITY network

findTargets

private ArrayList findTargets()
Get a list of all peers found in the VICINITY-network

Returns:
List of all peers which were found in the VICINITY network


Copyright © Fraunhofer Gesellschaft. All Rights Reserved.