|
|
|
|
@ -51,13 +51,21 @@ class _MyHomePageState extends State<MyHomePage> {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<String> getCurrentIP() async {
|
|
|
|
|
for (var interface in await NetworkInterface.list(type: InternetAddressType.IPv4)) {
|
|
|
|
|
log("interfaces: ${interface.name}");
|
|
|
|
|
final ips = await NetworkInterface.list(type: InternetAddressType.IPv4);
|
|
|
|
|
for (var interface in ips) {
|
|
|
|
|
//TODO: WE WILL UPDATE THIS WHEN TESTING ON SCREEN
|
|
|
|
|
// if (interface.name == "wlan0") {
|
|
|
|
|
if (interface.name == "eth0") {
|
|
|
|
|
for (var address in interface.addresses) {
|
|
|
|
|
deviceIPGlobal = address.address;
|
|
|
|
|
print("IP with eth0: ${address.address}");
|
|
|
|
|
return deviceIPGlobal;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (interface.name == "wlan0") {
|
|
|
|
|
for (var address in interface.addresses) {
|
|
|
|
|
deviceIPGlobal = address.address;
|
|
|
|
|
print("IP with wlan0: ${address.address}");
|
|
|
|
|
return deviceIPGlobal;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -76,7 +84,12 @@ class _MyHomePageState extends State<MyHomePage> {
|
|
|
|
|
signalRHelper.startSignalRConnection(await getCurrentIP(), onUpdateAvailable: onUpdateAvailable, onConnect: onConnect, onConnecting: onConnecting, onDisconnect: onDisconnect);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
audioPlayer.playerStateStream.listen((playerState) {
|
|
|
|
|
if (playerState.processingState == ProcessingState.completed) {
|
|
|
|
|
isCallingInProgress = false;
|
|
|
|
|
print("isCallingInProgress in Stream: $isCallingInProgress");
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
super.initState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -84,11 +97,6 @@ class _MyHomePageState extends State<MyHomePage> {
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
audioPlayer.playerStateStream.listen((playerState) {
|
|
|
|
|
if (playerState.processingState == ProcessingState.completed) {
|
|
|
|
|
isCallingInProgress = false;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
return AppScaffold(
|
|
|
|
|
appBar: AppHeader(),
|
|
|
|
|
body: dataContent(audioPlayer),
|
|
|
|
|
@ -152,6 +160,11 @@ class _MyHomePageState extends State<MyHomePage> {
|
|
|
|
|
|
|
|
|
|
Widget dataContent(AudioPlayer audioPlayer) {
|
|
|
|
|
voiceCall(audioPlayer);
|
|
|
|
|
// print("wlength: ${waitings.length}");
|
|
|
|
|
// if (waitings.length > callConfigsGlobal.screenMaxDisplayPatients) {
|
|
|
|
|
// final newList = waitings.sublist(0, callConfigsGlobal.screenMaxDisplayPatients );
|
|
|
|
|
// print("wlength: ${newList.length}");
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
if (waitings.isEmpty) {
|
|
|
|
|
// No Patient in Queue
|
|
|
|
|
@ -209,12 +222,14 @@ class _MyHomePageState extends State<MyHomePage> {
|
|
|
|
|
audioPlayer.setAsset("assets/tones/call_tone.mp3");
|
|
|
|
|
await audioPlayer.play();
|
|
|
|
|
await Future.delayed(const Duration(seconds: 2));
|
|
|
|
|
isCallingInProgress = false;
|
|
|
|
|
}
|
|
|
|
|
if (waitings.first.isVoiceReq && voiceCaller == null && !waitings.first.isQueue) {
|
|
|
|
|
final postVoice = getCallTypeText(waitings.first, callConfigsGlobal);
|
|
|
|
|
voiceCaller = CallByVoice(waitings.first.queueNo.trim().toString(), preVoice: "Ticket Number", postVoice: postVoice, lang: 'en');
|
|
|
|
|
voiceCaller = CallByVoice(preVoice: "Ticket Number", ticketNo: waitings.first.queueNo.trim().toString(), postVoice: postVoice, lang: 'en');
|
|
|
|
|
await voiceCaller.startCalling(waitings.first.queueNo.trim().toString() != waitings.first.callNoStr.trim().toString());
|
|
|
|
|
voiceCaller = null;
|
|
|
|
|
isCallingInProgress = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (isQueuePatients.isNotEmpty) {
|
|
|
|
|
@ -259,7 +274,11 @@ class _MyHomePageState extends State<MyHomePage> {
|
|
|
|
|
API.getCallRequestInfoByClinicInfo(deviceIPGlobal, onSuccess: (waitingCalls, isQueuePatientsCalls, callConfigs) {
|
|
|
|
|
setState(() {
|
|
|
|
|
callConfigsGlobal = callConfigs;
|
|
|
|
|
waitings = waitingCalls;
|
|
|
|
|
if (waitingCalls.length > callConfigsGlobal.screenMaxDisplayPatients) {
|
|
|
|
|
waitings = waitingCalls.sublist(0, callConfigsGlobal.screenMaxDisplayPatients);
|
|
|
|
|
} else {
|
|
|
|
|
waitings = waitingCalls;
|
|
|
|
|
}
|
|
|
|
|
isQueuePatients = isQueuePatientsCalls;
|
|
|
|
|
// currents = currentInClinic;
|
|
|
|
|
});
|
|
|
|
|
@ -279,8 +298,11 @@ class _MyHomePageState extends State<MyHomePage> {
|
|
|
|
|
// return;
|
|
|
|
|
// }
|
|
|
|
|
if (waitings.isNotEmpty) {
|
|
|
|
|
print("isCallingInProgress: ${isCallingInProgress}");
|
|
|
|
|
print("voiceCaller: ${voiceCaller == null}");
|
|
|
|
|
if ((waitings.first.isToneReq && isCallingInProgress) || (waitings.first.isVoiceReq && voiceCaller != null)) {
|
|
|
|
|
// if (true) {
|
|
|
|
|
print("I will wait now for ${callConfigsGlobal.concurrentCallDelaySec} seconds");
|
|
|
|
|
Timer(Duration(seconds: callConfigsGlobal.concurrentCallDelaySec), () async {
|
|
|
|
|
await callPatientsAPI();
|
|
|
|
|
});
|
|
|
|
|
@ -317,9 +339,10 @@ class _MyHomePageState extends State<MyHomePage> {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
listenNetworkConnectivity() async {
|
|
|
|
|
Connectivity().onConnectivityChanged.listen((event) {
|
|
|
|
|
Connectivity().onConnectivityChanged.listen((event) async {
|
|
|
|
|
switch (event) {
|
|
|
|
|
case ConnectivityResult.wifi:
|
|
|
|
|
await getCurrentIP();
|
|
|
|
|
signalRHelper.connection.start();
|
|
|
|
|
break;
|
|
|
|
|
case ConnectivityResult.none:
|
|
|
|
|
|