|
|
|
|
@ -17,7 +17,7 @@ import 'package:queuing_system/utils/signalR_utils.dart';
|
|
|
|
|
import 'package:queuing_system/utils/utils.dart';
|
|
|
|
|
import 'package:queuing_system/widget/data_display/app_texts_widget.dart';
|
|
|
|
|
|
|
|
|
|
var DEVICE_IP = "10.10.15.11"; // Testing IP
|
|
|
|
|
var deviceIPGlobal = "10.10.15.11"; // Testing IP
|
|
|
|
|
|
|
|
|
|
// var DEVICE_IP = "10.10.14.11"; // Testing IP
|
|
|
|
|
// var DEVICE_IP = "10.10.15.11";
|
|
|
|
|
@ -46,17 +46,18 @@ class _MyHomePageState extends State<MyHomePage> {
|
|
|
|
|
super.dispose();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<String> printIps() async {
|
|
|
|
|
Future<String> getCurrentIP() async {
|
|
|
|
|
for (var interface in await NetworkInterface.list(type: InternetAddressType.IPv4)) {
|
|
|
|
|
log("interfaces: ${interface.name}");
|
|
|
|
|
if (interface.name == "eth0") {
|
|
|
|
|
for (var address in interface.addresses) {
|
|
|
|
|
DEVICE_IP = address.address;
|
|
|
|
|
return DEVICE_IP;
|
|
|
|
|
deviceIPGlobal = address.address;
|
|
|
|
|
return deviceIPGlobal;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
@ -64,11 +65,10 @@ class _MyHomePageState extends State<MyHomePage> {
|
|
|
|
|
listenNetworkConnectivity();
|
|
|
|
|
scheduleMicrotask(() async {
|
|
|
|
|
if (!signalRHelper.getConnectionState()) {
|
|
|
|
|
signalRHelper.startSignalRConnection(await printIps(), onUpdateAvailable: onUpdateAvailable, onConnect: onConnect, onConnecting: onConnecting, onDisconnect: onDisconnect);
|
|
|
|
|
signalRHelper.startSignalRConnection(await getCurrentIP(), onUpdateAvailable: onUpdateAvailable, onConnect: onConnect, onConnecting: onConnecting, onDisconnect: onDisconnect);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
super.initState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -98,7 +98,7 @@ class _MyHomePageState extends State<MyHomePage> {
|
|
|
|
|
fontSize: SizeConfig.getWidthMultiplier() * 2.6,
|
|
|
|
|
fontFamily: 'Poppins-Medium.ttf',
|
|
|
|
|
),
|
|
|
|
|
Text(DEVICE_IP, style: TextStyle(fontWeight: FontWeight.w500, fontSize: SizeConfig.getWidthMultiplier() * 2.2)),
|
|
|
|
|
Text(deviceIPGlobal, style: TextStyle(fontWeight: FontWeight.w500, fontSize: SizeConfig.getWidthMultiplier() * 2.2)),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(width: 10),
|
|
|
|
|
@ -184,8 +184,8 @@ class _MyHomePageState extends State<MyHomePage> {
|
|
|
|
|
}
|
|
|
|
|
if (waitings.first.isVoiceReq && voiceCaller == null) {
|
|
|
|
|
final postVoice = getCallTypeText(waitings.first);
|
|
|
|
|
voiceCaller = CallByVoice(waitings.first.queueNo.toString(), preVoice: "Ticket Number", postVoice: postVoice, lang: 'en');
|
|
|
|
|
await voiceCaller.startCalling();
|
|
|
|
|
voiceCaller = CallByVoice(waitings.first.queueNo.trim().toString(), preVoice: "Ticket Number", postVoice: postVoice, lang: 'en');
|
|
|
|
|
await voiceCaller.startCalling(waitings.first.queueNo.trim().toString() != waitings.first.callNoStr.trim().toString());
|
|
|
|
|
voiceCaller = null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -227,13 +227,12 @@ class _MyHomePageState extends State<MyHomePage> {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onUpdateAvailable(data) async {
|
|
|
|
|
print("here is the data: $data");
|
|
|
|
|
if (isQueuePatients.isNotEmpty && callFlag == 0) {
|
|
|
|
|
callFlag = 1;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
waitings.clear();
|
|
|
|
|
API.getCallRequestInfoByClinicInfo(DEVICE_IP, onSuccess: (waitingCalls, isQueuePatientsCalls) {
|
|
|
|
|
API.getCallRequestInfoByClinicInfo(deviceIPGlobal, onSuccess: (waitingCalls, isQueuePatientsCalls) {
|
|
|
|
|
setState(() {
|
|
|
|
|
waitings = waitingCalls;
|
|
|
|
|
isQueuePatients = isQueuePatientsCalls;
|
|
|
|
|
@ -252,7 +251,7 @@ class _MyHomePageState extends State<MyHomePage> {
|
|
|
|
|
updateTickets() {
|
|
|
|
|
if (waitings != null && waitings.isNotEmpty) {
|
|
|
|
|
List<Tickets> _ticketsToUpdate = waitings.where((t) => t.callUpdated == false).toList();
|
|
|
|
|
API.callUpdateNotIsQueueRecordByIDAsync(DEVICE_IP, ticket: _ticketsToUpdate.first, onSuccess: (tickets_updated) {
|
|
|
|
|
API.callUpdateNotIsQueueRecordByIDAsync(deviceIPGlobal, ticket: _ticketsToUpdate.first, onSuccess: (tickets_updated) {
|
|
|
|
|
log("[${tickets_updated.length}] Tickets Updated: $tickets_updated");
|
|
|
|
|
}, onFailure: (e) {
|
|
|
|
|
log("API UPDate Tickets Failed with : ${e.toString()}");
|
|
|
|
|
@ -266,7 +265,7 @@ class _MyHomePageState extends State<MyHomePage> {
|
|
|
|
|
|
|
|
|
|
onDisconnect(exception) {
|
|
|
|
|
log("SignalR: onDisconnect");
|
|
|
|
|
signalRHelper.startSignalRConnection(DEVICE_IP, onUpdateAvailable: onUpdateAvailable, onConnect: onConnect, onConnecting: onConnecting, onDisconnect: onDisconnect);
|
|
|
|
|
signalRHelper.startSignalRConnection(deviceIPGlobal, onUpdateAvailable: onUpdateAvailable, onConnect: onConnect, onConnecting: onConnecting, onDisconnect: onDisconnect);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onConnecting() {
|
|
|
|
|
|