@Override
    public void update(Observable o, Object arg) {
        //System.out.println("update");
        if (o instanceof Server) {
            if (arg instanceof ChatMessage || arg instanceof ChatPerson) {
                try {
                    oOut.writeObject(arg);
                } catch (IOException ex) {
                    Logger.getLogger(ClientConnection.class.getName()).log(Level.SEVERE, null, ex);
                }
            } else if (arg instanceof ServerMessage) {
                if (((ServerMessage) arg).getServerCode() == 1) {
                    try {
                        oOut.writeObject(arg);
                    } catch (IOException ex) {
                        Logger.getLogger(ClientConnection.class.getName()).log(Level.SEVERE, null, ex);
                    }
                }
            }
        }
    }