rand
This commit is contained in:
parent
41959d0962
commit
7ed15be770
@ -35,13 +35,13 @@ function sleep(ms) {
|
||||
|
||||
function addUser(user, peerId) {
|
||||
connectedUsers.push({ name: user, peerId: peerId });
|
||||
sidebarBox.setContent(connectedUsers.map(user => `${user.name} - ${user.peerId}`).join("\n"));
|
||||
sidebarBox.setContent(connectedUsers.map(user => `${user.peerId}`).join("\n"));
|
||||
screen.render();
|
||||
}
|
||||
|
||||
function removeUser(peerId) {
|
||||
connectedUsers = connectedUsers.filter(user => user.peerId !== peerId);
|
||||
sidebarBox.setContent("Connected Peers: \n" + connectedUsers.map(user => `${user.name} - ${user.peerId}`).join("\n"));
|
||||
sidebarBox.setContent("Peers since connection: \n" + connectedUsers.map(user => `${user.peerId}`).join("\n"));
|
||||
screen.render();
|
||||
}
|
||||
|
||||
@ -218,7 +218,7 @@ swarm.on('connection', conn => {
|
||||
const name = b4a.toString(conn.remotePublicKey, 'hex')
|
||||
console.log(`* got a connection from ${name} (${USERNAME[0]}) *`)
|
||||
addUser(USERNAME[0], name)
|
||||
sidebarBox.setLabel("Connected Peers: " + connectedUsers.length)
|
||||
sidebarBox.setLabel("Peers since connection: " + connectedUsers.length)
|
||||
screen.render()
|
||||
conns.push(conn)
|
||||
conn.once('close', () => conns.splice(conns.indexOf(conn), 1))
|
||||
|
Loading…
Reference in New Issue
Block a user