Skip to content

Instantly share code, notes, and snippets.

@gladimdim
Created April 11, 2019 08:44
Show Gist options
  • Select an option

  • Save gladimdim/a38bd16db0f4aab9ebfff61d3de1dd06 to your computer and use it in GitHub Desktop.

Select an option

Save gladimdim/a38bd16db0f4aab9ebfff61d3de1dd06 to your computer and use it in GitHub Desktop.
class Responder {
final ResponderType type;
Call call;
final String name;
Responder({this.type, this.name});
void respondToCall(Call incoming) {
if (isBusy()) {
throw ResponderBusyException('Responder $name of type $type is busy.');
}
call = incoming;
}
bool isBusy() {
return this.call != null;
}
endCurrentCall() {
if (this.isBusy()) {
var temp = call;
call = null;
temp.endCall();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment