forked from agree-able/breakout-room
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathcli.mjs
More file actions
executable file
·27 lines (21 loc) · 787 Bytes
/
cli.mjs
File metadata and controls
executable file
·27 lines (21 loc) · 787 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/usr/bin/env node
import { BreakoutRoom } from './index.mjs'
const invite = process.argv[2]
async function run () {
const room = new BreakoutRoom({ invite })
const hostInvite = await room.ready()
if (hostInvite) console.log('Give out invite:', hostInvite)
// send room messages from standard in
process.stdin.on('data', async (data) => await room.message(data.toString()))
room.on('peerEntered', (peerKey) => console.log('peer entered the room', peerKey))
room.on('peerLeft', async (peerKey) => {
console.log('peer left the room', peerKey)
})
room.on('message', async (m) => {
console.log('remote message recieved', m)
const transcript = await room.getTranscript()
console.log('Transcript:', transcript)
})
room.installSIGHandlers()
}
run()