31
Oct
Black Art of Java Game Programming by Joel
p2.add(L); p2.repaint(); p2.layout(); L.addItem(”All Participants”); StringTokenizer st2 = new StringTokenizer(val, “&”); while(st2.hasMoreTokens()) L.addItem(st2.nextToken()); L.select(0); } else if(cmd.equals(”logout”)) { int x; for(x=0;x< L.getRows();x++) if( val.startsWith( L.getItem(x) ) ) L.delItem(x); outputArea.appendText(val+"n"); validate(); } else if(cmd.equals("login")) { outputArea.appendText(st.nextToken()+"n"); } else outputArea.appendText( val + "n" ); } else outputArea.appendText(str + "n"); } catch (IOException e) { /* if we get an IOException, it almost certainly means the connection was lost */ System.out.println("Connection lost."); kicker.stop(); } } } The stop( ) Method Because we are such nice, tidy programmers, we must make sure that the Socket and its related streams get closed before we finish. We also want to let the server know that we are logging out. To do this, we override the stop() method and make sure it cleans up before it exits: public void stop() { output("logout||"+name); try { dis.close();
Hint: If you are looking for very good and affordable webspace to host and run your j2ee hosting application check Virtualwebstudio j2ee web hosting services
