Last active
June 26, 2020 09:39
-
-
Save codebanesr/f8209a89c6dfba7f97f8bec3f3727f6b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
switch (data.type) { | |
case 'offer': | |
// Doctor will initiate the offer | |
// console.log('msg received', Object.keys(this.connections), data, connection.userData); | |
// if UserB exists then send him offer detail | |
// TODO: if patient has joined then send the offer. else send message that patient not available | |
// to check patient has joined | |
// get oversides connection | |
if (aptData && aptData.userConnectionId) { | |
// get connectionId of patient and send offer | |
conn = this.connections[aptData.userConnectionId]; | |
if (conn != null) { | |
// setting that UserA connected with UserB | |
console.log('name sending for offer', aptData.userConnectionId) | |
this.sendTo(conn, { | |
type: 'offer', | |
offer: data.offer, | |
}); | |
} | |
} else { | |
// Patient is unavailable or have not joined yet. | |
this.sendAppointmentMsg(connection, { | |
type: 'appointment-status', | |
data: 'Patient is not available yet', | |
}); | |
} | |
break; | |
``` | |
1.Remove this logic altogether, the patient doesnot necessarily have to be available when doctor has joined, | |
he can join later on as well | |
2.When you create the jwt add userid information in that.Once you have the userid, check if its a doctor registered in | |
the database, if yes create a room `socket.join(roomName)`, the room name will be the same as docktors userid, | |
When the patient wants to join the chat redirect him to the same room the doctor is in. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment