-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d31e3df
commit 3a70b9e
Showing
23 changed files
with
469 additions
and
417 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,35 @@ | ||
import User from "../models/User"; | ||
|
||
export interface PeerInviteProps { | ||
friend: User; | ||
inviteFriendToRoom: (id: string) => void; | ||
friend: User; | ||
inviteFriendToRoom: (id: string) => void; | ||
} | ||
|
||
function PeerInvite({friend, inviteFriendToRoom}: PeerInviteProps) { | ||
return ( | ||
<li className="flex flex-row justify-center gap-4"> | ||
<img | ||
src={friend.profile_picture} | ||
className="rounded-full w-14 h-14 border-my-orange border-2 object-cover" | ||
/> | ||
<div className="flex flex-col justify-evenly items-center gap-2"> | ||
<p className="font-semibold"> | ||
<span className=""> | ||
{" "} | ||
{friend.first_name} {friend.last_name}{" "} | ||
</span> | ||
</p> | ||
<div className="flex flex-col xl:flex-row"> | ||
<button | ||
className={`btn small bg-my-green text-xs`} | ||
onClick={() => inviteFriendToRoom(friend.id)} | ||
> | ||
invite | ||
</button> | ||
</div> | ||
|
||
function PeerInvite({ friend, inviteFriendToRoom }: PeerInviteProps) { | ||
return ( | ||
<li className="flex flex-row justify-center gap-4"> | ||
<img | ||
src={friend.profile_picture} | ||
className="rounded-full w-14 h-14 border-my-orange border-2 object-cover" | ||
/> | ||
<div className="flex flex-col justify-evenly items-center gap-2"> | ||
<p className="font-semibold"> | ||
<span className=""> | ||
{" "} | ||
{friend.first_name} {friend.last_name}{" "} | ||
</span> | ||
</p> | ||
<div className="flex flex-col xl:flex-row"> | ||
<button | ||
className={`btn small bg-my-green text-xs`} | ||
onClick={() => inviteFriendToRoom(friend.id)} | ||
> | ||
invite | ||
</button> | ||
</div> | ||
</li> | ||
); | ||
} | ||
|
||
</div> | ||
</li> | ||
); | ||
} | ||
|
||
export default PeerInvite; | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,34 @@ | ||
import { useEffect, useRef, useState } from "react"; | ||
import dataService from "../services/data"; | ||
interface RoomPeerVideoProps { | ||
remoteStream: MediaStream; | ||
peerId: string; | ||
remoteStream: MediaStream; | ||
peerId: string; | ||
} | ||
function RoomPeerVideo({remoteStream, peerId}: RoomPeerVideoProps) { | ||
const remoteRef = useRef<HTMLVideoElement>(null); | ||
const [name, setName] = useState(""); | ||
const fetchFullName = async () => { | ||
const fullNameRequest = await dataService.fetchData(`/users/${peerId}/name`, "GET", {}); | ||
const fullName = fullNameRequest.fullName; | ||
setName(fullName); | ||
function RoomPeerVideo({ remoteStream, peerId }: RoomPeerVideoProps) { | ||
const remoteRef = useRef<HTMLVideoElement>(null); | ||
const [name, setName] = useState(""); | ||
const fetchFullName = async () => { | ||
const fullNameRequest = await dataService.fetchData( | ||
`/users/${peerId}/name`, | ||
"GET", | ||
{}, | ||
); | ||
const fullName = fullNameRequest.fullName; | ||
setName(fullName); | ||
}; | ||
useEffect(() => { | ||
if (remoteStream) { | ||
remoteRef.current!.srcObject = remoteStream; | ||
remoteRef.current!.play(); | ||
} | ||
useEffect(() => { | ||
if (remoteStream) { | ||
remoteRef.current!.srcObject = remoteStream; | ||
remoteRef.current!.play(); | ||
} | ||
fetchFullName(); | ||
}, []); | ||
return ( | ||
<div className="flex flex-col items-center gap-4"> | ||
<video | ||
ref={remoteRef} | ||
></video> | ||
<div>{name}</div> | ||
</div> | ||
) | ||
fetchFullName(); | ||
}, []); | ||
return ( | ||
<div className="flex flex-col items-center gap-4"> | ||
<video ref={remoteRef}></video> | ||
<div>{name}</div> | ||
</div> | ||
); | ||
} | ||
|
||
export default RoomPeerVideo; | ||
export default RoomPeerVideo; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
async function fetchUserMedia() { | ||
const localStream = await navigator.mediaDevices.getUserMedia({ | ||
video: true, | ||
audio: true | ||
}); | ||
return localStream; | ||
const localStream = await navigator.mediaDevices.getUserMedia({ | ||
video: true, | ||
audio: true, | ||
}); | ||
return localStream; | ||
} | ||
|
||
export default fetchUserMedia; | ||
export default fetchUserMedia; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
interface RoomNotification { | ||
from: string; | ||
roomId: string; | ||
title: string; | ||
to: string; | ||
userName: string; | ||
from: string; | ||
roomId: string; | ||
title: string; | ||
to: string; | ||
userName: string; | ||
} | ||
export default RoomNotification; | ||
export default RoomNotification; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
interface RoomPeer { | ||
peerId?: string; | ||
stream: MediaStream; | ||
fullName?: string; | ||
peerId?: string; | ||
stream: MediaStream; | ||
fullName?: string; | ||
} | ||
export default RoomPeer; | ||
export default RoomPeer; |
Oops, something went wrong.