Skip to content

Commit ee2bc68

Browse files
authored
Merge pull request #90 from WhyAsh5114/56
56
2 parents c646906 + 0258676 commit ee2bc68

15 files changed

Lines changed: 1189 additions & 1213 deletions

File tree

package-lock.json

Lines changed: 187 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
"@huggingface/inference": "^3.6.2",
6565
"@mediapipe/tasks-vision": "^0.10.22-rc.20250304",
6666
"@prisma/client": "^6.5.0",
67+
"agora-rtc-sdk-ng": "^4.23.2",
6768
"barqode": "^0.0.2",
6869
"better-auth": "^1.2.5",
6970
"canvas": "^3.1.0",

prisma/schema.prisma

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ datasource db {
99
}
1010

1111
model User {
12-
id String @id @default(cuid())
12+
id String @id @default(cuid())
1313
name String
1414
email String
1515
emailVerified Boolean
@@ -20,8 +20,6 @@ model User {
2020
accounts Account[]
2121
Macros Macros[]
2222
Onboarding Onboarding[]
23-
createdRooms Room[] @relation("RoomCreator")
24-
roomsJoined RoomParticipant[]
2523
HeartRate HeartRate[]
2624
Routines Routines[]
2725
@@ -100,37 +98,6 @@ model Onboarding {
10098
user User @relation(fields: [userId], references: [id])
10199
}
102100

103-
model Room {
104-
id String @id @default(cuid())
105-
name String?
106-
createdAt DateTime @default(now())
107-
updatedAt DateTime @updatedAt
108-
creatorId String
109-
creator User @relation("RoomCreator", fields: [creatorId], references: [id])
110-
participants RoomParticipant[]
111-
status RoomStatus @default(STARTING)
112-
113-
@@map("room")
114-
}
115-
116-
enum RoomStatus {
117-
STARTING
118-
ACTIVE
119-
CLOSED
120-
}
121-
122-
model RoomParticipant {
123-
id String @id @default(cuid())
124-
roomId String
125-
room Room @relation(fields: [roomId], references: [id], onDelete: Cascade)
126-
userId String
127-
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
128-
joinedAt DateTime @default(now())
129-
130-
@@unique([roomId, userId])
131-
@@map("room_participant")
132-
}
133-
134101
model HeartRate {
135102
id String @id @default(cuid())
136103
user User @relation(fields: [userId], references: [id])

src/lib/agora.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import AgoraRTC, { type ICameraVideoTrack, type IMicrophoneAudioTrack } from 'agora-rtc-sdk-ng';
2+
3+
const appId = '989389d78f284ae4bf4524ac7e09e1b3'; // Replace with your Agora app ID
4+
5+
export const agoraClient = AgoraRTC.createClient({
6+
mode: 'rtc',
7+
codec: 'vp8'
8+
});
9+
10+
export async function createLocalTracks(): Promise<{
11+
videoTrack: ICameraVideoTrack;
12+
}> {
13+
const videoTrack = await AgoraRTC.createCameraVideoTrack();
14+
return { videoTrack };
15+
}
16+
17+
export async function joinChannel(channelName: string, uid: number) {
18+
try {
19+
await agoraClient.join(appId, channelName, null, uid);
20+
const { videoTrack } = await createLocalTracks();
21+
await agoraClient.publish([videoTrack]);
22+
return { videoTrack };
23+
} catch (error) {
24+
console.error('Error joining channel:', error);
25+
throw error;
26+
}
27+
}
28+
29+
export async function leaveChannel() {
30+
agoraClient.remoteUsers.forEach((user) => {
31+
const playerContainer = document.getElementById(`player-${user.uid}`);
32+
playerContainer?.remove();
33+
});
34+
await agoraClient.leave();
35+
}

src/lib/components/ProfileCard.svelte

Whitespace-only changes.

0 commit comments

Comments
 (0)