Add kick player and leave game functionality
- Host can kick players from lobby (removes from game, clears presenter if needed) - Client can voluntarily leave game - Fix browser-compatible base64 decoding for document upload (atob vs Buffer)
This commit is contained in:
parent
3122748bae
commit
79820f5298
7 changed files with 1640 additions and 10 deletions
|
|
@ -130,11 +130,20 @@ function transformToQuiz(data: any): Quiz {
|
|||
}
|
||||
|
||||
async function uploadNativeDocument(ai: GoogleGenAI, doc: ProcessedDocument): Promise<{ uri: string; mimeType: string }> {
|
||||
const buffer = typeof doc.content === 'string'
|
||||
? Buffer.from(doc.content, 'base64')
|
||||
: doc.content;
|
||||
let data: ArrayBuffer;
|
||||
|
||||
const blob = new Blob([buffer], { type: doc.mimeType });
|
||||
if (typeof doc.content === 'string') {
|
||||
const binaryString = atob(doc.content);
|
||||
const bytes = new Uint8Array(binaryString.length);
|
||||
for (let i = 0; i < binaryString.length; i++) {
|
||||
bytes[i] = binaryString.charCodeAt(i);
|
||||
}
|
||||
data = bytes.buffer as ArrayBuffer;
|
||||
} else {
|
||||
data = doc.content;
|
||||
}
|
||||
|
||||
const blob = new Blob([data], { type: doc.mimeType });
|
||||
|
||||
const uploadedFile = await ai.files.upload({
|
||||
file: blob,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue