示例#1
0
  /** the constructor */
  public PrivateClient(Client parent, ClientInterface selfIdentity) throws RemoteException {
    super(parent.getUserName() + " in private session with " + selfIdentity.getUserName());

    this.parent = parent;
    this.selfIdentity = selfIdentity;

    this.server = this.parent.getClassServer();

    this.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent ev) {
            selfRemove();
            ev.getWindow().dispose();
          }
        });

    initComponents();
    lineSeparator = System.getProperty("line.separator");
  }
  public void run() {
    ClientInterface ci = new ClientInterface(dataBase);

    while (true) {
      System.out.println();
      try {
        byte[] headerData;

        headerData = readRequestHeader();
        ci.setMember(headerData);
        // ci.printMember();

        if (Define.objec.SYSTEM == ci.getObjec()) {
          if (Define.order.MAJORITYCREATE == ci.getOrder()) {
            dataBase.createMajority(ci.getDataOfMajority());
          } else if (Define.order.MAJORITYADD == ci.getOrder()) {
            dataBase.addMajority(ci.getDataOfMajority());
          } else if (Define.order.MAJORITYRESET == ci.getOrder()) {
            dataBase.resetMajority();
          }
        } else if (Define.objec.NODE == ci.getObjec()) {
          if (Define.order.CREATE == ci.getOrder()) {
            Node createNode = ci.getCreateNode();
            dataBase.registrationNode(createNode, clientNumber);
          } else if (Define.order.EDIT == ci.getOrder()) {
            Node createNode = ci.getCreateNode();
            System.out.println(
                "EditidentNumber = " + createNode.identNumber); // /////////////////////////
            dataBase.EditNode(createNode, clientNumber);
          } else if (Define.order.DELETE == ci.getOrder()) {
            ID delID = ci.getDelId();
            dataBase.DelateNode(delID);
          } else {
            // 未実装
          }
        } else if (Define.objec.AGENDA == ci.getObjec()) {
          if (Define.order.CREATE == ci.getOrder()) {
            AgendaPacket ciAgendaPacket = ci.getAgendaPacket();
            dataBase.getAgendaDataBase().addNode(ciAgendaPacket, ciAgendaPacket.getID());
          }
        }

        Vector cloneDatabase = (Vector) dataBase.getDataBaseClone();
        Vector tempDatabase = (Vector) cloneDatabase.get(0);
      } catch (IOException e) {
        // TODO 自動生成された catch ブロック
        e.printStackTrace();
        break;
      }
    }
  }
示例#3
0
 /** Displays a new incomming private message. */
 public void displayPrivateMessage(ClientInterface from, String message) throws RemoteException {
   ta.append("<" + from.getUserName() + ">: " + message + lineSeparator);
   ta.setCaretPosition(ta.getText().length());
 }
示例#4
0
  /** The method tests if this object is equal to another. */
  public boolean equals(ClientInterface cli) throws RemoteException {
    if (selfIdentity.equals(cli)) return true;

    return false;
  }