@Override public void windowClosing(WindowEvent e) { // TODO Auto-generated method stub System.out.println(name + ": window closed!! logging out..."); try { model.logout(name); } catch (Exception ex) { ex.printStackTrace(); } finally { System.exit(0); } }
@Override public void mouseClicked(MouseEvent e) { // TODO Auto-generated method stub if (state == STATE.DISCONNECTED) { System.out.println("server is disconnected!"); return; } Rectangle rect = view.getFlyDimension(); if (rect.contains(e.getPoint())) { System.out.println(name.toString() + " hit the fly!!"); try { model.sendFlyHitConfirmation(name); } catch (Exception ex) { ex.printStackTrace(); } } }
// Constructor to initialize client name and server location public C_GameClient(String name, String serverLoc) throws RemoteException, MalformedURLException, NotBoundException { model = new M_GameClient(name, this); Naming.rebind("client", model); this.name = name; SERVER_STUB_LOC = serverLoc; setSize(400, 400); setVisible(true); setTitle("Game Client - " + this.name); addWindowListener(this); view = new V_GameClient(); view.setName(name); view.setMouseListener(gameMouseListener); add(view); model.login(name, model); state = STATE.CONNECTED; }