Example #1
0
 @Override
 public boolean equals(Object obj) {
   boolean eq = false;
   if (obj instanceof Offer) {
     Offer otherOffer = (Offer) obj;
     eq = request.equals(otherOffer.getRequest());
   }
   return eq;
 }
Example #2
0
 /**
  * Create an offer based on the request.
  *
  * @param request The request this offer is for
  * @param queue The request queue that is sending this offer to the agents.
  * @param rejectionTimeout the number of milliseconds to wait until expiring an agent rejection.
  */
 public Offer(Request request, RequestQueue queue, long rejectionTimeout) {
   this.request = request;
   this.queue = queue;
   this.rejectionTimeout = rejectionTimeout;
   offerTime = new Date();
   cancelled = false;
   invitationSent = false;
   request.setOffer(this);
 }
Example #3
0
  public void cancel() {
    cancelled = true;

    // Handle when customer cancels.
    if (!pendingSessions.isEmpty() || !acceptedSessions.isEmpty()) {
      for (AgentSession session : pendingSessions) {
        request.sendRevoke(session, queue);
      }
      for (AgentSession session : acceptedSessions) {
        request.sendRevoke(session, queue);
      }
      pendingSessions.clear();
      acceptedSessions.clear();
      updateUserSession(USER_CANCELLED);
    } else {
      updateUserSession(ROUTE_EXPIRED);
    }
  }
Example #4
0
 public void invite(AgentSession agentSession) {
   if (acceptedSessions.contains(agentSession) && request != null) {
     // Ask the workgroup to send invitations to the agent and to the user that made the
     // request. The Workgroup will create a MUC room and send invitations to the agent and
     // the user.
     request.offerAccepted(agentSession);
     updateUserSession(ROUTED);
     invitationSent = true;
   }
 }
Example #5
0
 public void waitForResolution() {
   long timeoutTime = offerTime.getTime() + timeout;
   while (timeoutTime > System.currentTimeMillis()
       && !isAccepted()
       && !pendingSessions.isEmpty()) {
     try {
       Thread.sleep(500); // half second polling
     } catch (InterruptedException e) {
       // do nothing
     }
   }
   if (!isAccepted()) {
     try {
       for (AgentSession session : pendingSessions) {
         request.sendRevoke(session, queue);
         reject(session);
       }
     } catch (Exception e) {
       // Ignore
     }
   }
 }
Example #6
0
 /**
  * Updates the database tables with new session state, waitTime and metadata.
  *
  * @param state the state of this session.
  */
 private void updateUserSession(int state) {
   // Update the current session.
   request.updateSession(state, offerTime.getTime());
 }
Example #7
0
 @Override
 public int hashCode() {
   return request.hashCode();
 }