Pusher Swift 成员 added/removed 事件

Pusher Swift member added/removed event

我正在使用 Pusher Swift right now, but I can't find a properly way to handle the member_added and member_removed methods. In LibPusher(objective-c 实现)存在 PTPusherPresenceChannelDelegate 和 memberAdded 和 memberRemoved 方法,但在 Pusher Swift 中没有t.

订阅正常

let presenceChannel = pusher.subscribe("presence-channel")
    presenceChannel.bind("pusher:subscription_succeeded", callback: { (data: AnyObject?) -> Void in
        //It's ok!
    })

如何处理这个事件?谢谢

当您订阅状态频道时,您可以包含闭包来处理 "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)