┌──────────────────────────────────────────────────┬────────────────────────────────────────────────────┐
│Patient App │ Dr App │
└──────────────────────────────────────────────────┴────────────────────────────────────────────────────┘
CallActivity —————————————————————————————————————————————————————————▶︎ Incoming Activity
│
┌───────────────────────────────────────────────┐ │
│event emit: "notify" │ │
│json: │ │
│{ "to": roomId, │ │
│ "from": mySocketId, │ │
│ "msgType": "notifyTypeGeneral", │ │
│ "call_id": callId, │ │
│ "appointment_id": aptId, │ │
│ "room_id": roomId, │ │
│ "caller_id": doctorId or patientId, │ │
│ "caller": callerName, │ │
│ "caller_username": callerName, │ │
│ "caller_image": callerPicUrl │ │
│} │ │
└───────────────────────────────────────────────┘ │
│
▼
Accept Call
|
▼
Call Activity Open
|
▼
PeerConnectionClient <——Send Offer——————————————————————————————————— PeerConnectionClient
(Set Offer) (Set Candidate) (Create Offer) (Candidate)
│ _________________________________________________
│ │JSONObject msgJo = new JSONObject(); │
│ │msgJo.put("sdp", sdp.description); │
│ │msgJo.put("type", "offer"); //offer │
│ │Sting msgStr = msgJo.toString(); │
│ │ │
│ │String messageJo new JSONObj(); │
│ │messageJo.put("cmd", "send"); │
│ │messageJo.put("msg", msgStr); │
│ │String messageStr = messageJo.toString(); │
│ │ │
│ │event emit: "notify" │
│ │json: │
│ │{ │
│ │ "to": roomID, │
│ │ "from": mySocketId, │
│ │ "msgType": "notifyTypeExchange", │
│ │ "message": messageStr │
│ │} │
│ ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
│
|
▼
(Create Answer ) ——————————————————————————Send Answer ————————————————————> (Set Answer)
_________________________________________________
│JSONObject msgJo = new JSONObject(); │
│msgJo.put("sdp", sdp.description); │
│msgJo("type", "answer"); //answer │
│Sting msgStr = msgJo.toString(); │
│ │
│JSONObject messageJo = new JSONObject(); |
|messageJo.put("cmd", "send"); |
|messageJo.put("msg", msgStr); |
|String messageStr = messageJo.toString(); │
│ │
│event emit: "notify" │
│json: │
│{ │
│ "to": roomID, │
│ "from": mySocketId, │
│ "msgType": "notifyTypeExchange", │
│ "message": messageStr │
│} │
‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
|
▼
(Candidate) ——————————————————————— Send Candidate —————————————————————————> (Set Candidate)
_________________________________________________
│JSONObject msgJo = new JSONObject(); │
│msgJo.put("type", "candidate"); //candidate │
│msgJo.put("label", candidate.sdpMLineIndex); │
│msgJo.put("id", candidate.sdpMid); │
│msgJo.put("candidate", candidate.sdp); |
│ |
│Sting msgStr = msgJo.toString(); |
| |
│JSONObject messageJo = new JSONObject(); |
|messageJo.put("cmd", "send"); |
|messageJo.put("msg", msgStr); |
|String messageStr = messageJo.toString(); |
| |
│event emit: "notify" │
│json: │
│{ │
│ "to": roomID, │
│ "from": mySocketId, │
│ "msgType": "notifyTypeExchange", │
│ "message": messageStr │
│} │
‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
event emit: "notify"
json:
{
"to", roomId,
"from", mySocketId,
"msgType", "notifyTypeCallStatus",
"call_id", callId,
"appointment_id", roomId,
"room_id", roomId,
"call_status", callStatus
}
Different CallStatus: "connecting", "ringing", "accept", "reject", "connected", "disconnected", "reconnecting"
for both doctor and patient app
event emit: "notify"
json:
{ "to": roomId,
"from": mySocketId,
"msgType": "notifyTypeGeneral",
"call_id", callId,
"appointment_id", roomId,
"room_id", roomId,
"leave_call", true
}