|
|
|
@ -35,6 +35,8 @@ class CallProvider with ChangeNotifier, DiagnosticableTreeMixin {
|
|
|
|
|
|
|
|
|
|
|
|
bool isLoading = false;
|
|
|
|
bool isLoading = false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String currentStatus = "Connecting...";
|
|
|
|
|
|
|
|
|
|
|
|
Future<void> _disposeConnection() async {
|
|
|
|
Future<void> _disposeConnection() async {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
if (callHubConnection != null) {
|
|
|
|
if (callHubConnection != null) {
|
|
|
|
@ -216,7 +218,7 @@ class CallProvider with ChangeNotifier, DiagnosticableTreeMixin {
|
|
|
|
String? senderN;
|
|
|
|
String? senderN;
|
|
|
|
String? recipientN;
|
|
|
|
String? recipientN;
|
|
|
|
bool? isVideo;
|
|
|
|
bool? isVideo;
|
|
|
|
int? moduleId;
|
|
|
|
int moduleId = 1004;
|
|
|
|
int? referenceID;
|
|
|
|
int? referenceID;
|
|
|
|
|
|
|
|
|
|
|
|
Function(String message)? onFailed;
|
|
|
|
Function(String message)? onFailed;
|
|
|
|
@ -226,27 +228,29 @@ class CallProvider with ChangeNotifier, DiagnosticableTreeMixin {
|
|
|
|
this.senderN = senderN;
|
|
|
|
this.senderN = senderN;
|
|
|
|
this.recipientN = recipientN;
|
|
|
|
this.recipientN = recipientN;
|
|
|
|
this.isVideo = isVideo;
|
|
|
|
this.isVideo = isVideo;
|
|
|
|
this.moduleId = moduleId;
|
|
|
|
// this.moduleId = moduleId;
|
|
|
|
this.referenceID = referenceID;
|
|
|
|
this.referenceID = referenceID;
|
|
|
|
this.onFailed = onFailed;
|
|
|
|
this.onFailed = onFailed;
|
|
|
|
this.onSuccess = onSuccess;
|
|
|
|
this.onSuccess = onSuccess;
|
|
|
|
invoke(invokeMethod: "CallUserAsync", currentUserID: senderN!, targetUserID: recipientN!, isVideoCall: isVideo!);
|
|
|
|
invoke(invokeMethod: "CallUserAsync", currentUserID: senderN!, targetUserID: recipientN!, isVideoCall: isVideo!, data: [this.moduleId, referenceID]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void acceptCall(String senderN, String recipientN, bool isVideo) async {
|
|
|
|
void acceptCall(String senderN, String recipientN, bool isVideo, {required int moduleId}) async {
|
|
|
|
invoke(invokeMethod: "AnswerCallAsync", currentUserID: senderN, targetUserID: recipientN, isVideoCall: isVideo);
|
|
|
|
invoke(invokeMethod: "AnswerCallAsync", currentUserID: senderN, targetUserID: recipientN, isVideoCall: isVideo, data: [this.moduleId]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Future declineCall(String senderN, String recipientN) async {
|
|
|
|
Future declineCall(String senderN, String recipientN, {required int moduleId}) async {
|
|
|
|
await invoke(invokeMethod: "CallDeclinedAsync", currentUserID: senderN, targetUserID: recipientN, isVideoCall: false);
|
|
|
|
await invoke(invokeMethod: "CallDeclinedAsync", currentUserID: senderN, targetUserID: recipientN, isVideoCall: false, data: [this.moduleId]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void endCall(String senderN, String recipientN) {
|
|
|
|
void endCall(String senderN, String recipientN, {required int moduleId}) {
|
|
|
|
invoke(invokeMethod: "HangUpAsync", currentUserID: senderN, targetUserID: recipientN);
|
|
|
|
invoke(invokeMethod: "HangUpAsync", currentUserID: senderN, targetUserID: recipientN, data: [moduleId]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void toggleMute() {
|
|
|
|
void toggleMute() async {
|
|
|
|
invoke(invokeMethod: "AudioToggle", currentUserID: senderN!, targetUserID: recipientN!, isVideoCall: isVideo!);
|
|
|
|
await invoke(invokeMethod: "AudioToggle", currentUserID: senderN!, targetUserID: recipientN!);
|
|
|
|
|
|
|
|
isMuted = !isMuted;
|
|
|
|
|
|
|
|
notifyListeners();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void checkCall(Map<String, dynamic> message) {
|
|
|
|
void checkCall(Map<String, dynamic> message) {
|
|
|
|
@ -323,7 +327,7 @@ class CallProvider with ChangeNotifier, DiagnosticableTreeMixin {
|
|
|
|
|
|
|
|
|
|
|
|
void onAudioToggle(List<Object?>? params) {
|
|
|
|
void onAudioToggle(List<Object?>? params) {
|
|
|
|
print("onAudioToggle: $params");
|
|
|
|
print("onAudioToggle: $params");
|
|
|
|
isMuted = !isMuted;
|
|
|
|
isPeerMuted = !isPeerMuted;
|
|
|
|
notifyListeners();
|
|
|
|
notifyListeners();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -335,16 +339,19 @@ class CallProvider with ChangeNotifier, DiagnosticableTreeMixin {
|
|
|
|
|
|
|
|
|
|
|
|
Future<void> invoke({required String invokeMethod, required String currentUserID, required String targetUserID, bool isVideoCall = false, var data}) async {
|
|
|
|
Future<void> invoke({required String invokeMethod, required String currentUserID, required String targetUserID, bool isVideoCall = false, var data}) async {
|
|
|
|
List<Object> args = [];
|
|
|
|
List<Object> args = [];
|
|
|
|
|
|
|
|
if (data != null) {
|
|
|
|
|
|
|
|
data = data.toString().replaceFirst("[", "").replaceFirst("]", "");
|
|
|
|
|
|
|
|
}
|
|
|
|
if (invokeMethod == "AnswerCallAsync") {
|
|
|
|
if (invokeMethod == "AnswerCallAsync") {
|
|
|
|
args = [currentUserID, targetUserID];
|
|
|
|
args = [currentUserID, targetUserID, data];
|
|
|
|
} else if (invokeMethod == 'CallDeclinedAsync') {
|
|
|
|
} else if (invokeMethod == 'CallDeclinedAsync') {
|
|
|
|
args = [currentUserID, targetUserID];
|
|
|
|
args = [currentUserID, targetUserID, data];
|
|
|
|
} else if (invokeMethod == "CallUserAsync") {
|
|
|
|
} else if (invokeMethod == "CallUserAsync") {
|
|
|
|
args = [currentUserID, targetUserID, isVideoCall];
|
|
|
|
args = [currentUserID, targetUserID, isVideoCall];
|
|
|
|
} else if (invokeMethod == "HangUpAsync") {
|
|
|
|
} else if (invokeMethod == "HangUpAsync") {
|
|
|
|
args = [currentUserID, targetUserID];
|
|
|
|
args = [currentUserID, targetUserID, data];
|
|
|
|
} else if (invokeMethod == "AudioToggle") {
|
|
|
|
} else if (invokeMethod == "AudioToggle") {
|
|
|
|
args = [currentUserID, targetUserID, isVideoCall];
|
|
|
|
args = [currentUserID, targetUserID];
|
|
|
|
} else if (invokeMethod == "IceCandidateAsync") {
|
|
|
|
} else if (invokeMethod == "IceCandidateAsync") {
|
|
|
|
args = [targetUserID, data];
|
|
|
|
args = [targetUserID, data];
|
|
|
|
} else if (invokeMethod == "OfferAsync") {
|
|
|
|
} else if (invokeMethod == "OfferAsync") {
|
|
|
|
@ -376,6 +383,8 @@ class CallProvider with ChangeNotifier, DiagnosticableTreeMixin {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
} else if (params[0] == 'USER_BUSY') {
|
|
|
|
} else if (params[0] == 'USER_BUSY') {
|
|
|
|
onFailed?.call("The user is currently busy on another call");
|
|
|
|
onFailed?.call("The user is currently busy on another call");
|
|
|
|
|
|
|
|
} else if (params[0] == 'USER_DECLINE') {
|
|
|
|
|
|
|
|
onFailed?.call("Call Declined, User has declined your call.");
|
|
|
|
} else if (params[0] == 'USER_OFFLINE') {
|
|
|
|
} else if (params[0] == 'USER_OFFLINE') {
|
|
|
|
onFailed?.call("The user is currently offline");
|
|
|
|
onFailed?.call("The user is currently offline");
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
|