Skip to content

Commit

Permalink
Show users already in classroom
Browse files Browse the repository at this point in the history
  • Loading branch information
jac committed Mar 20, 2021
1 parent 2fe15d4 commit fbe696c
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 27 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# AstraTutor

This repo serves as the monorepo for the GrindsApp application for Team 4 of the CS3305 Team Software Project module
This repo serves as the monorepo for the AstraTutor application for Team 4 of the CS3305 Team Software Project module

## Instructions

Expand Down
Binary file removed signalling/signalling
Binary file not shown.
4 changes: 4 additions & 0 deletions ui/src/views/LessonClassroom.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,10 @@ export function LessonClassroom(): ReactElement {

const type: MESSAGE_TYPE = message.type;
switch (type) {
case MESSAGE_TYPE.PROBE: {
signalling.send(MESSAGE_TYPE.PROBE_RESPONSE, message.src, settings.otherProfiles[signalling.id]);
break;
}
case MESSAGE_TYPE.AHOY_HOY: {
handler.current!.addPeer(message.src);
break;
Expand Down
48 changes: 24 additions & 24 deletions ui/src/views/LessonLobby.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ export function LessonLobby(): ReactElement {
const [otherProfiles, setOtherProfiles] = React.useState<{ [id: string]: ProfileResponseDTO }>({});
const [metadata, setMetadata] = useState<LessonResponseDTO>();
const [completed, setCompleted] = useState(false);
const [alreadyInClass, setAlreadyInClass] = useState<ProfileResponseDTO[] | undefined>(undefined);

if (!joined && !history.location.pathname.endsWith('lobby')) {
history.push(`/lessons/${lid}/lobby`);
Expand All @@ -106,11 +107,20 @@ export function LessonLobby(): ReactElement {
};

const connect = () => {
signalling.current = new Signalling(api.claims?.sub ?? '', `${config.signallingUrl}/${lid}`, {
signalling.current = new Signalling(api.claims!.sub, `${config.signallingUrl}/${lid}`, {
onopen: (event: Event) => {
console.log('Connected to WS: ', lid);
// TODO(james): Probe Users
// signalling.current?.send(MESSAGE_TYPE.PROBE, '', null);
signalling.current?.send(MESSAGE_TYPE.PROBE, '', null);
},
onmessage: (event) => {
const message = JSON.parse(event.data);
if (message.src === api.claims!.sub) return;
if (message.to !== undefined && message.to !== api.claims!.sub) return;

const type: MESSAGE_TYPE = message.type;
if (type === MESSAGE_TYPE.PROBE_RESPONSE) {
setAlreadyInClass(alreadyInClass ? alreadyInClass.concat(message.data) : [message.data]);
}
},
onclose: () => {
setTimeout(() => {
Expand Down Expand Up @@ -301,31 +311,21 @@ export function LessonLobby(): ReactElement {
Joining your {metadata?.subject_name} classroom!
</Typography.Title>
</Typography>
{/* TODO(james): Send probe message to discover users */}
<Typography style={{ textAlign: 'center' }}>
<Typography.Text style={{ color: '#fff' }}>Already in this meeting:</Typography.Text>
</Typography>
<Row align="middle" justify="center">
<Col>
<Avatar.Group size="default">
<Tooltip title="Gamer">
<UserAvatar
profile={{
account_id: '1',
avatar: '',
slug: '/',
first_name: 'Gamer',
last_name: 'Jones',
city: 'Cark',
country: 'Ireland',
subtitle: 'Gamer',
description: 'Gamer',
color: '#199a4c',
}}
/>
</Tooltip>
</Avatar.Group>
</Col>
{alreadyInClass?.map((profile) => {
return (
<Col key={profile.account_id}>
<Avatar.Group size="default">
<Tooltip title={`${profile.first_name} ${profile.last_name}`}>
<UserAvatar profile={profile} />
</Tooltip>
</Avatar.Group>
</Col>
);
})}
</Row>
<br />
<Row align="middle" justify="center">
Expand Down
4 changes: 3 additions & 1 deletion ui/src/webrtc/signalling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ export interface Callbacks {
}

export enum MESSAGE_TYPE {
AHOY_HOY = 1,
PROBE = 1,
PROBE_RESPONSE,
AHOY_HOY,
CHAT,
SDP,
CANDIDATE,
Expand Down
2 changes: 1 addition & 1 deletion ui/src/webrtc/webrtc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ export class WebRTCHandler {
}

addTrack(track: MediaStreamTrack, kind: StreamType, stream: MediaStream) {
if (this.tracks[track.id]) return;
if (this.tracks[track.id] || stream.getTrackById(track.id) === null) return;

console.log('Adding Track: ', track);
this.tracks[track.id] = [stream, kind];
Expand Down

0 comments on commit fbe696c

Please sign in to comment.