-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #157 from platinouss/feature/231127-multi-room
Feature(#30, #45, #87, #146, #156): ๋ฏธ๋์ด ์๋ฒ์์ ์ฌ๋ฌ ๊ฐ์์ค์ ๊ด๋ฆฌํ๊ณ , ํ์ดํธ๋ณด๋ & ์ง๋ฌธ & ๊ฐ์ ์ข ๋ฃ & ๊ฐ์ ๋๊ฐ๊ธฐ๋ฅผ ์ง์ํ๋ค
- Loading branch information
Showing
10 changed files
with
229 additions
and
90 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { RTCPeerConnection } from 'wrtc'; | ||
|
||
export enum ClientType { | ||
PRESENTER, | ||
STUDENT | ||
} | ||
|
||
export class ClientInfo { | ||
private readonly _type: ClientType; | ||
private readonly _RTCPC: RTCPeerConnection; | ||
private _roomId: string; | ||
|
||
constructor(type: ClientType, RTCPC: RTCPeerConnection) { | ||
this._type = type; | ||
this._RTCPC = RTCPC; | ||
this._roomId = ''; | ||
} | ||
|
||
get type(): ClientType { | ||
return this._type; | ||
} | ||
|
||
get RTCPC(): RTCPeerConnection { | ||
return this._RTCPC; | ||
} | ||
|
||
set roomId(roomId: string) { | ||
this._roomId = roomId; | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export class Message { | ||
type: string; | ||
content: string; | ||
|
||
constructor(type: string, content: string) { | ||
this.type = type; | ||
this.content = content; | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { RTCPeerConnection } from 'wrtc'; | ||
import { Socket } from 'socket.io'; | ||
|
||
export class RoomInfo { | ||
private readonly _roomId: string; | ||
private readonly _RTCPC: RTCPeerConnection; | ||
private readonly _presenterSocket: Socket; | ||
private readonly _studentSocketList: Set<Socket>; | ||
private _stream: MediaStream | null; | ||
|
||
constructor(roomId: string, socket: Socket, RTCPC: RTCPeerConnection) { | ||
this._roomId = roomId; | ||
this._presenterSocket = socket; | ||
this._studentSocketList = new Set(); | ||
this._RTCPC = RTCPC; | ||
this._stream = null; | ||
} | ||
|
||
get presenterSocket(): Socket { | ||
return this._presenterSocket; | ||
} | ||
|
||
get studentSocketList(): Set<Socket> { | ||
return this._studentSocketList; | ||
} | ||
|
||
set stream(presenterStream: MediaStream) { | ||
this._stream = presenterStream; | ||
} | ||
|
||
get stream(): MediaStream | null { | ||
return this._stream; | ||
} | ||
|
||
endLecture = () => { | ||
this._studentSocketList.forEach((student: Socket) => { | ||
student.leave(this._roomId); | ||
}); | ||
this._presenterSocket.leave(this._roomId); | ||
}; | ||
|
||
exitRoom = (studentSocket: Socket) => { | ||
studentSocket.leave(this._roomId); | ||
this._studentSocketList.delete(studentSocket); | ||
}; | ||
} |
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import dotenv from 'dotenv'; | ||
|
||
dotenv.config(); | ||
|
||
export const pc_config = { | ||
iceServers: [ | ||
{ | ||
urls: ['stun:stun.l.google.com:19302'] | ||
}, | ||
{ | ||
urls: process.env.TURN_URL as string, | ||
username: process.env.TURN_USERNAME as string, | ||
credential: process.env.TURN_PASSWORD as string | ||
} | ||
] | ||
}; |
Oops, something went wrong.