我现在正在使用Pusher Swift,但我找不到合适的方法来处理member_added和member_removed方法。在LibPusher(objective-c实现)中存在 PTPusherPresenceChannelDelegate 和memberAdded以及memberRemoved方法,但是在Pusher Swift中没有。
订阅它工作正常
let presenceChannel = pusher.subscribe("presence-channel")
presenceChannel.bind("pusher:subscription_succeeded", callback: { (data: AnyObject?) -> Void in
//It's ok!
})
如何处理此事件?感谢
答案 0 :(得分:3)
当您订阅在线频道时,您可以包含关闭以处理" onMemberAdded"和" onMemberRemoved"事件。
来自PusherSwift cocoapod docs:
let onMemberAdded = { (member: PresenceChannelMember) in
//Do something with the new member
print(member)
}
let onMemberRemoved = { (member: PresenceChannelMember) in
//Do something with the removed member
print(member)
}
let chan = pusher.subscribe("presence-channel", onMemberAdded: onMemberAdded, onMemberRemoved: onMemberRemoved)