-
Notifications
You must be signed in to change notification settings - Fork 3
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
Showing
4 changed files
with
87 additions
and
23 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
|
||
interface Room { | ||
roomId: string, | ||
locked: false, | ||
owner: string, | ||
presenter?: string, | ||
streams: any, | ||
} | ||
|
||
|
||
interface Stream { | ||
name: string, | ||
audio: boolean, | ||
video: boolean, | ||
screen: boolean, | ||
} | ||
|
||
async function newRoom(): Promise<Room> { | ||
return (await fetch(`/room/`, { | ||
method: "POST", | ||
})).json() | ||
} | ||
|
||
async function getRoom(roomId: string): Promise<Room> { | ||
return (await fetch(`/room/${roomId}`)).json() | ||
} | ||
|
||
async function setRoom(roomId: string, data: any): Promise<Room> { | ||
return (await fetch(`/room/${roomId}`, { | ||
headers: { | ||
"Content-Type": "application/json", | ||
}, | ||
method: "PATCH", | ||
body: JSON.stringify(data), | ||
})).json() | ||
} | ||
|
||
async function delRoom(roomId: string): Promise<void> { | ||
return (await fetch(`/room/${roomId}`, { | ||
method: "DELETE", | ||
})).json() | ||
} | ||
|
||
async function newStream(roomId: string): Promise<Stream> { | ||
return (await fetch(`/room/${roomId}/stream`, { | ||
method: "POST", | ||
})).json() | ||
} | ||
|
||
async function setStream(roomId: string, streamId: string, data: any): Promise<Stream> { | ||
return (await fetch(`/room/${roomId}/stream/${streamId}`, { | ||
headers: { | ||
"Content-Type": "application/json", | ||
}, | ||
method: "PATCH", | ||
body: JSON.stringify(data), | ||
})).json() | ||
} | ||
|
||
async function delStream(roomId: string, streamId: string): Promise<void> { | ||
return (await fetch(`/room/${roomId}/stream/${streamId}`, { | ||
method: "DELETE", | ||
})).json() | ||
} | ||
|
||
export { | ||
newRoom, | ||
getRoom, | ||
setRoom, | ||
delRoom, | ||
|
||
newStream, | ||
setStream, | ||
delStream, | ||
} |