Ejemplo n.º 1
0
 @Override
 public void participantJoinedConversation(Participant p) {
   super.participantJoinedConversation(p);
   c.displayNEWWebpage(p, "ID1", "Instructions", "", 430, 540, false, false);
   c.changeWebpageTextAndColour(
       p, "ID1", "Please wait for other participant to log in", "white", "black");
   if (c.getParticipants().getAllParticipants().size() > 2) {
     at.startTask(
         (Participant) c.getParticipants().getAllParticipants().elementAt(0),
         (Participant) c.getParticipants().getAllParticipants().elementAt(1),
         (Participant) c.getParticipants().getAllParticipants().elementAt(2));
   }
 }
Ejemplo n.º 2
0
  @Override
  public synchronized void processChatText(Participant sender, MessageChatTextFromClient mct) {
    pTurnsElapsed.setValue(((Integer) pTurnsElapsed.getValue()) + 1);
    super.expSettings.generateParameterEvent(pTurnsElapsed);
    if (mct.getText().startsWith("/")) {
      // actionquery = "";
      at.processSelection(sender, mct.getText());
      c.setNewTurnBeingConstructedNotRelayingOldTurnAddingOldTurnToHistory(sender, mct);
      if (!queryaction) return;
    }

    Move mostRecent = null;
    String clarification = "";
    String haystack = mct.getText();
    if (mct.getText().startsWith("/")) haystack = mct.getText().substring(1);
    // if(mct.getText().startsWith(haystack));

    // System.err.println(haystack);
    // System.exit(-4);

    // search for clarification
    if ((queryturns | (mct.getText().startsWith("/") & queryaction))
        & this.targetRecipient != null
        & sender == this.targetRecipient
        & ((this.interventionstage == this.istageEARLY & at.getLastSel() == 0)
            | (this.interventionstage == this.istageLATE & at.getLastSel() > 0)
            | (this.interventionstage == this.istageBOTH))) {
      // System.exit(-5);
      Object[] allMatches = at.getMostRecentAndAllMovesForString(haystack);
      mostRecent = (Move) allMatches[0];
      Vector allmentionedMoves = (Vector) allMatches[1];
      for (int i = 0; i < allmentionedMoves.size(); i++) {
        Move mv = (Move) allmentionedMoves.elementAt(i);
        Conversation.printWSln("Main", "IDENTIFIED: " + i + "): " + mv.getName());
      }

      if (onlyForMostRecent && mostRecent != null) {
        clarification = mostRecent.getName() + "?";
        this.displayInterventionInfo("MOSTRECENT MOVE FOUND -WAITING FOR TIMEOUT");
      } else if (!onlyForMostRecent & allmentionedMoves.size() > 0) {
        // int moveindex = 0;
        Move m = (Move) allmentionedMoves.elementAt(0);
        // Move m = (Move)allmentionedMoves.elementAt(r.nextInt(allmentionedMoves.size()));
        clarification = m.getName() + "?";
      }
    }
    if (clarification != null & !clarification.equalsIgnoreCase("")) {
      if (!mct.getText().startsWith("/")) c.relayTurnToAllOtherParticipants(sender, mct);
      if (this.isinCRSubdialogue) return;
      final String interventiontext = "" + clarification;
      clarification = "";
      Vector v = c.getParticipants().getAllOtherParticipants(sender);
      Participant pAppOrig;
      if (this.targetAppOrigIsOverhearer) {
        pAppOrig = at.getOverhearer(sender);
      } else {
        pAppOrig = at.getOther(sender);
      }

      // c.sendAndEnableLabelDisplayToAllowedParticipantsFromApparentOrigin(sender, "Network
      // problem..recalculating", true, false);
      c.sendAndEnableLabelDisplayToAllOtherParticipantsFromApparentOriginInOwnStatusWindow(
          sender, "Network problem..recalculating", true, false);
      // c.sendArtificialTurnToAllOtherParticipants(sender, "THISSHOULD...");
      // c.sendAndEnableLabelDisplayToAllowedParticipantsFromApparentOrigin(sender, "Network
      // problem..recalculating", true, false);
      // c.sendLabelDisplayToParticipantInOwnStatusWindow(c, interventiontext, isCompleted);
      this.numberOfDelaysPreFragSending++;
      this.displayInterventionInfo("MOSTRECENT MOVE FOUND -WAITING FOR TIMEOUT");
      try {
        Thread.sleep(this.timeout_beforeonset);
      } catch (Exception e) {
      }
      if (sender.isTyping(this.timeout_beforeonset - 500)) {
        this.displayInterventionInfo("ABORTED - THEY TYPED");
        c.sendAndEnableLabelDisplayToAllowedParticipantsFromApparentOrigin(
            sender, "Network OK", false, true);
        return;
      }
      this.numberOfFragsSent++;
      this.setRecordFragSent(sender.getUsername(), at.getLastSel());
      Conversation.printWSln("Main", "INTERVENTION IS:" + interventiontext);
      Conversation.printWSln("Main", this.getRecordFragsSent());

      final Participant senderCopy = sender;

      Thread t =
          new Thread() {
            public void run() {
              try {
                long starttime = new Date().getTime();
                int seconds = 0;
                while (starttime + timeout_whiletyping > new Date().getTime()) {
                  Thread.sleep(1000);
                  seconds = seconds + 1;
                  int timeremaining =
                      (int) ((starttime + timeout_whiletyping) - (new Date().getTime())) / 1000;
                  displayInterventionInfo(timeremaining + ": " + interventiontext);
                }

              } catch (Exception ee) {
              }

              try {
                // displayInterventionInfo("5: "+interventiontext);
                // Thread.sleep(1500);displayInterventionInfo("4: "+interventiontext);
                // Thread.sleep(1500);displayInterventionInfo("3:
                // "+interventiontext);Thread.sleep(1500);displayInterventionInfo("2:
                // "+interventiontext);Thread.sleep(1500);
                // displayInterventionInfo("1: "+interventiontext);Thread.sleep(1500);
                // displayInterventionInfo("0-REENABLED");
                c.sendAndEnableLabelDisplayToAllowedParticipantsFromApparentOrigin(
                    senderCopy, "Normal text", false, true);
                isinCRSubdialogue = false;
                targetRecipient = null;
                at.jcrs.interventionOVER();
              } catch (Exception e) {
              }
            }
          };

      isinCRSubdialogue = true;
      c.sendArtificialTurnFromApparentOriginToRecipient(
          pAppOrig, targetRecipient, interventiontext);
      t.start();
      return;
    }
    // cnt++;
    if (!mct.getText().startsWith("/")) {
      c.relayTurnToAllOtherParticipants(sender, mct);
      c.sendLabelDisplayToAllowedParticipantsFromApparentOrigin(sender, "Status: OK", false);
    }
    // c.sendAndEnableLabelDisplayToAllOtherParticipantsFromApparentOriginInOwnStatusWindow(sender,
    // "Network problem..recalculating"+cnt, false, false);

    // System.exit(-3);
  }
Ejemplo n.º 3
0
 public void unblockC() {
   c.sendLabelDisplayAndEnableToParticipantInOwnStatusWindow(at.getC(), "Network OK", false, true);
 }
Ejemplo n.º 4
0
 public void blockC() {
   c.sendLabelDisplayAndEnableToParticipantInOwnStatusWindow(
       at.getC(), "Network problem...recalculating", true, false);
 }
Ejemplo n.º 5
0
 public void swapAWithB() {
   at.swapAWithC();
 }
Ejemplo n.º 6
0
 public void swapBWithC() {
   at.swapBWithC();
 }