Skip to content

Instantly share code, notes, and snippets.

@Nazmul56
Last active July 4, 2020 07:08
Show Gist options
  • Save Nazmul56/92427d7b2a128e1ff5fac7c2ad6e9e3f to your computer and use it in GitHub Desktop.
Save Nazmul56/92427d7b2a128e1ff5fac7c2ad6e9e3f to your computer and use it in GitHub Desktop.

Notify Event Usages

┌──────────────────────────────────────────────────┬────────────────────────────────────────────────────┐
│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			│
│}						│
‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾

Call Status

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"

End call

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
}    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment