Methods Summary |
---|
public void | addHandler(EventHandler eh)
if (!globalHandlers.contains(eh)) {
globalHandlers.addElement(eh);
}
|
public void | addHandler(EventHandler eh, java.util.EventObject e)
Class eClass = e.getClass();
addHandler(eh, eClass);
|
public void | addHandler(EventHandler eh, java.lang.Class ec)
Vector evHandlers = (Vector)handlers.get(ec);
if (evHandlers == null) {
evHandlers = new Vector();
handlers.put(ec, evHandlers);
}
if (!evHandlers.contains(eh)) {
evHandlers.addElement(eh);
}
|
void | connect(java.net.InetAddress a, int port)
try {
Socket s = new Socket(a, port);
evIn = s.getInputStream();
evOut = s.getOutputStream();
}
catch (Exception e) {
evIn = null;
evOut = null;
}
|
void | distributeEvent(java.util.EventObject ev)
// Send event to all "global" handlers
Enumeration e = globalHandlers.elements();
while (e.hasMoreElements()){
EventHandler h = (EventHandler)e.nextElement();
h.handleEvent(ev);
}
// Send event to handlers targetting the event's class
Class evClass = ev.getClass();
Vector evHandlers = (Vector)handlers.get(evClass);
e = evHandlers.elements();
while (e.hasMoreElements()) {
EventHandler h = (EventHandler)e.nextElement();
h.handleEvent(ev);
}
|
public void | handleEvent(java.util.EventObject e)
|
java.util.EventObject | receiveEvent()
ObjectInputStream oin = new ObjectInputStream(evIn);
EventObject ev = null;
try {
ev = (EventObject)oin.readObject();
}
catch (ClassCastException e) {
System.out.println("Non-event object sent to EventTransceiver");
}
catch (ClassNotFoundException e2) {
System.out.println("Unresolvable object type sent to EventTransceiver");
}
return ev;
|
public void | removeHandler(EventHandler eh)
globalHandlers.removeElement(eh);
Enumeration ecList = handlers.keys();
while (ecList.hasMoreElements()) {
Vector evHandlers =
(Vector)handlers.get(ecList.nextElement());
if (evHandlers != null) {
evHandlers.removeElement(eh);
}
}
|
public void | removeHandler(EventHandler eh, java.util.EventObject e)
removeHandler(eh, e.getClass());
|
public void | removeHandler(EventHandler eh, java.lang.Class ec)
Vector evHandlers = (Vector)handlers.get(ec);
if (evHandlers != null) {
evHandlers.removeElement(eh);
}
|
public void | run()
try {
while (true) {
EventObject e = receiveEvent();
if (e != null)
distributeEvent(e);
}
}
// Treat an IOException as termination of the event
// input stream, and let this handler thread die
catch (IOException e) {}
|
public void | sendEvent(java.util.EventObject ev)
ObjectOutputStream oout = new ObjectOutputStream(evOut);
oout.writeObject(ev);
|
void | setStreams(java.io.InputStream in, java.io.OutputStream out)
evIn = in;
evOut = out;
|