|
|
|
|
@ -30,11 +30,11 @@ class Signaling {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
initializeSignalR() async{
|
|
|
|
|
initializeSignalR(String userName) async{
|
|
|
|
|
if(signalR != null)
|
|
|
|
|
await signalR.closeConnection();
|
|
|
|
|
|
|
|
|
|
signalR = SignalRUtil(hubName: "https://VCallApi.hmg.com/WebRTCHub?source=$My_Mobile&username=$My_ID");
|
|
|
|
|
// https://vcallapi.hmg.com/webRTCHub?source=web&username=zohaib
|
|
|
|
|
signalR = SignalRUtil(hubName: "https://vcallapi.hmg.com/webRTCHub?source=mobile&username=$userName");
|
|
|
|
|
final connected = await signalR.openConnection();
|
|
|
|
|
if(!connected)
|
|
|
|
|
throw 'Failed to connect SignalR';
|
|
|
|
|
@ -55,19 +55,19 @@ class Signaling {
|
|
|
|
|
MediaStream remoteStream;
|
|
|
|
|
RTCDataChannel dataChannel;
|
|
|
|
|
|
|
|
|
|
Future<bool> call(String patientId, String mobile, {@required RTCVideoRenderer localVideo, @required RTCVideoRenderer remoteVideo}) async {
|
|
|
|
|
initializeSignalR();
|
|
|
|
|
|
|
|
|
|
final isCallPlaced = await FCM.sendCallNotifcationTo(DOCTOR_TOKEN, patientId, mobile);
|
|
|
|
|
if(!isCallPlaced)
|
|
|
|
|
throw 'Failed to notify target for call';
|
|
|
|
|
|
|
|
|
|
return isCallPlaced;
|
|
|
|
|
}
|
|
|
|
|
// Future<bool> call(String patientId, String mobile, {@required RTCVideoRenderer localVideo, @required RTCVideoRenderer remoteVideo}) async {
|
|
|
|
|
// await initializeSignalR(patientId);
|
|
|
|
|
//
|
|
|
|
|
// // final isCallPlaced = await FCM.sendCallNotifcationTo(DOCTOR_TOKEN, patientId, mobile);
|
|
|
|
|
// if(!isCallPlaced)
|
|
|
|
|
// throw 'Failed to notify target for call';
|
|
|
|
|
//
|
|
|
|
|
// return isCallPlaced;
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Future<bool> acceptCall(String caller, String receiver, {@required MediaStream localMediaStream, @required Function(MediaStream) onRemoteMediaStream}) async{
|
|
|
|
|
await initializeSignalR();
|
|
|
|
|
await initializeSignalR(receiver);
|
|
|
|
|
signalR.setContributors(caller: caller, receiver: receiver);
|
|
|
|
|
await signalR.acceptCall(receiver, caller).catchError((e) => throw 'Failed to inform signalR that i accepted a call');
|
|
|
|
|
|
|
|
|
|
@ -143,7 +143,7 @@ class Signaling {
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
peerConnection?.onConnectionState = (RTCPeerConnectionState state) {
|
|
|
|
|
print('Connection state change: $state');
|
|
|
|
|
print('Connection state change: $state ${state.index}');
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
peerConnection?.onSignalingState = (RTCSignalingState state) {
|
|
|
|
|
|