def do_call(self, call_id): #If the call input is correct if call_id != '': call = Call(call_id) print("Call " + call_id + " received") #Adding call to the list of calls which are happening self.online_calls_list.addCall(call) #Flag to see if call is going to queue or not go_queue = True if self.call_queue.isEmpty(): #Look for operator available op = self.searchOperator("available") if op is not None: #Allocate call to operator print("Call " + call_id + " ringing for operator " + op.ID) self.operators.setCall(op.ID, call) go_queue = False #If is going to queue if go_queue: print("Call " + call_id + " waiting in queue") call.setStatus("waiting") self.call_queue.enqueue(call) else: print('Must specify a call id ( Call <call_id>)')
def call(self, call_id, protocol): answer_message = '' # If the call input is correct if call_id != '': call = Call(call_id) answer_message += "Call " + call_id + " received\n" # Adding call to the list of calls which are happening self.online_calls_list.addCall(call) # Flag to see if call is going to queue or not go_queue = True # Check if the is going to the queue if self.call_queue.isEmpty(): # Look for operator available op = self.searchOperator("available") if op is not None: answer_message += "Call " + call_id + " ringing for operator " + op.getID( ) + "\n" # Allocate call to operator self.operators.setCall(op.getID(), call) go_queue = False self.call_Check(op.getID(), call_id, protocol) # reactor.callLater(10, self.checkTimeOut, op.getID(), call_id, protocol) # If is going to queue if go_queue: answer_message += "Call " + call_id + " waiting in queue\n" call.setStatus("waiting") self.call_queue.enqueue(call) else: answer_message = 'Must specify a call id ( Call <call_id>)\n' return answer_message