show user channels

This commit is contained in:
data 2019-07-23 19:11:01 +01:00
parent e325a13156
commit a119cf0c6a
2 changed files with 6 additions and 3 deletions

View File

@ -4,8 +4,8 @@ module.exports = io => {
socket.join('#chat', () => {
sendAllRooms()
sendAllUsers()
socket.emit('get my rooms', socket.rooms)
send_rooms()
send_user_rooms()
})
socket.on('message', message => {
@ -27,6 +27,7 @@ module.exports = io => {
console.log('join:', roomName)
socket.join(roomName, () => {
sendAllRooms()
send_user_rooms()
})
})
@ -77,11 +78,12 @@ module.exports = io => {
)
}
function send_user_rooms() {
console.log(socket.rooms)
socket.emit(
'received my rooms',
Object.keys(socket.rooms).map(k => ({
Object.keys(io.sockets.adapter.rooms).map(k => ({
roomName: k,
sockets: socket.rooms[k]['socket'],
sockets: io.sockets.adapter.rooms[k]['sockets'],
}))
)
}

View File

@ -27,6 +27,7 @@ class App extends React.Component {
async fetchData() {
this.setState({ loading: false })
this.socket.emit('get my rooms')
}
componentDidMount() {