01: /*
02: * SocketConnectionEvent
03: *
04: * A subclass of TclEvent used to indicate that a connection
05: * has been made to a server socket.
06: */
07: package tcl.lang;
08:
09: public class SocketConnectionEvent extends TclEvent {
10:
11: Interp cbInterp;
12: TclObject callbackCmd;
13:
14: public SocketConnectionEvent(Interp i, TclObject cb, String chan,
15: String ip, int port) {
16: cbInterp = i;
17: callbackCmd = TclString.newInstance(cb.toString());
18: TclString.append(callbackCmd, " " + chan + " " + ip + " "
19: + port);
20: }
21:
22: public int processEvent(int flags) {
23: // Check this event is for us.
24: if ((flags == 0)
25: || ((flags & TCL.FILE_EVENTS) == TCL.FILE_EVENTS)
26: || ((flags & TCL.ALL_EVENTS) == TCL.ALL_EVENTS)) {
27: // Process the event
28: try {
29: cbInterp.eval(callbackCmd, TCL.EVAL_GLOBAL);
30: } catch (Exception e) {
31: // What do I do with this??
32: e.printStackTrace();
33: // Possibly the interpreter doesn't exist anymore??
34: }
35: return 1;
36: } else {
37: System.out.println("Event type: " + flags);
38: // Event not for us
39: return 0;
40: }
41: }
42:
43: }
|