예제 #1
0
  @Override
  public TraversalResults traverse(ImgVertex startVertex) {
    TraversalResults results = null;
    Date startDate, endDate;
    // Socket to talk to server
    try {
      startDate = new Date();
      Message message = prepareRequestMsg(startVertex);

      requester.send(Message.convertMessageToBytes(message), 0);

      byte[] reply = requester.recv(0);

      TraversalRepMsg traversalRepMsg = (TraversalRepMsg) Message.readFromBytes(reply);

      if (traversalRepMsg.isCompletedSuccesfully()) {
        results = readTraversalRepMsg(reply).getTraversalResults();
        endDate = new Date();
        results.setTime(endDate.getTime() - startDate.getTime());
      }

    } catch (Exception x) {
      x.printStackTrace();
    }

    return results;
  }
예제 #2
0
 private TraversalRepMsg readTraversalRepMsg(byte[] msg)
     throws IOException, ClassNotFoundException {
   return (TraversalRepMsg) Message.readFromBytes(msg);
 }