streamy
streamy copied to clipboard
Correct way to close dirrect sessions
Below this:
Streamy.sessionsForUsers(uid)
This method behaves similarly to sessions, however it looks up the sessions based on user id(s). It returns a special object which contains one method: emit which works the same as the core#emit method.
I have a question: What is the correct way to close returned this 'special object'? Just assigned to 'null' after end of use it? But in such way it doesn't work.... after I close window and has on detach this lines:
`
Streamy.off(this.selectedChat._id);
Streamy.close()
if (this.streamy)
this.streamy = null
`
I still get events in DEBUG console like this:
Object {senderId: "Yy9jfaxxtLcHWeQvS", status: "", __from: "4MgyX38TroGc7c3TL", msg: "streamy$mPqyC2Yv7jbPN5CG9"}
And in the beginning:
` refreshStreamy() { Streamy.off(this.selectedChat._id)
Streamy.onConnect(() => {
console.log('streamy connected!');
})
Streamy.onDisconnect(() => {
console.log('streamy disconnected!');
})
let userIdList = this.selectedChat.memberIds.filter(id => id !== Meteor.user()._id)
if (userIdList.length > 0)
this.streamy = Streamy.sessionsForUsers(userIdList);
Streamy.on(this.selectedChat._id, (data) => {
this.zone.run(() => {
this.refreshUserActions(data)
})
})
`