Created
April 11, 2019 09:41
-
-
Save gladimdim/f5043fa120d3b7b8b6d8e85c94ab6753 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dispatchCall(Call call) { | |
Responder processor; | |
for (var i = 0; i < allProcessors.length; i++) { | |
try { | |
processor = allProcessors[i].firstWhere((Responder p) => !p.isBusy()); | |
} catch (e) { | |
print('Switching to next level'); | |
continue; | |
} | |
if (processor != null) { | |
break; | |
} | |
} | |
// if all processors are busy we add call to queue | |
if (processor == null) { | |
queueCalls.add(call); | |
} else { | |
processor.respondToCall(call); | |
// we add a callback listener to now when the call is ended to | |
// check the queue and do other stuff in CallCenter | |
call.addEndCallback(callEnded); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment