joining and leaving backend side done and now agora test here we go

This commit is contained in:
Arjun Patel
2022-02-07 21:57:17 -08:00
parent 8d382f960a
commit 1bc7957824
8 changed files with 235 additions and 26 deletions
+2 -4
View File
@@ -13,7 +13,7 @@ import AgoraRTC, {
import { getFunctions, httpsCallable } from "firebase/functions";
import toast from "react-hot-toast";
const config: ClientConfig = {
export const config: ClientConfig = {
mode: "rtc",
codec: "vp8",
};
@@ -22,7 +22,7 @@ const config: ClientConfig = {
// const useMicrophoneTracks = createMicrophoneAudioTrack();
// TODO: move this to env file
const appId: string = "c8dfd65deb5c4741bd564085627139d0"; //ENTER APP ID HERE
export const appId: string = "c8dfd65deb5c4741bd564085627139d0"; //ENTER APP ID HERE
export default class AgoraService {
private functions = getFunctions();
@@ -90,5 +90,3 @@ export default class AgoraService {
// }
// }
}
export { appId };
@@ -8,6 +8,8 @@ import {
setDoc,
runTransaction,
writeBatch,
arrayUnion,
arrayRemove,
} from "firebase/firestore";
import Conversation, {
AudioClip,
@@ -179,7 +181,33 @@ export default class ConversationService {
},
{ merge: true }
);
}
return false;
async joinLiveConversation(convoId: string, userJoiningId: string) {
// todo: make sure that user is part of the convo or valid in it
const docRef = doc(this.db, Collections.conversations, convoId);
await setDoc(
docRef,
{
membersInLiveRoom: arrayUnion(userJoiningId),
lastActivityDate: serverTimestamp(),
lastUpdatedBy: userJoiningId,
},
{ merge: true }
);
}
async leaveLiveConversation(convoId: string, userJoiningId: string) {
// todo: make sure that user is part of the convo or valid in it
const docRef = doc(this.db, Collections.conversations, convoId);
await setDoc(
docRef,
{
membersInLiveRoom: arrayRemove(userJoiningId),
lastActivityDate: serverTimestamp(),
lastUpdatedBy: userJoiningId,
},
{ merge: true }
);
}
}
+3
View File
@@ -1,3 +1,4 @@
import AgoraService from "./agoraService";
import CloudStorageService from "./cloudStorageService";
import ConversationService from "./conversationService";
import UserService from "./userService";
@@ -7,3 +8,5 @@ export const conversationService = new ConversationService();
export const userService = new UserService();
export const cloudStorageService = new CloudStorageService();
export const agoraService = new AgoraService();