测试经过测试 | ✓ |
Lang语言 | SwiftSwift |
许可证 | MIT |
发布最后发布 | 2017年5月 |
SwiftSwift 版本 | 3.0 |
SPM支持 SPM | ✓ |
由 Jack Cook 维护。
依赖 | |
Starscream | ~> 2.0 |
SwiftyJSON | ~> 3.1 |
这是一个用 Swift 编写的 Beam 客户端库。
要运行示例项目,首先克隆仓库,然后在 Example 目录中运行 pod install
。
import BeamAPI
BeamClient.sharedClient.channels.getChannelWithId(252) { (channel, error) in
guard let channel = channel else {
return
}
print("\(channel.token) has \(channel.viewersCurrent) viewers.")
}
import BeamAPI
class ChatReceiver: NSObject, ChatClientDelegate {
// Connect to the channel with an id of 252
func start() {
let client = ChatClient(delegate: self)
client.joinChannel(252)
}
// Called when a connection is made to the chat server
func chatDidConnect() {
print("connected to chat")
}
// Called when the chat server sent us a packet
func chatReceivedPacket(packet: Packet) {
if let packet = packet as? MessagePacket {
print("message received: \(packet.messageText)")
}
}
// Called when there is a new viewer count available
func updateWithViewers(viewers: Int) {
print("\(viewers) are watching")
}
}
BeamAPI 可在 MIT 许可证下使用。有关更多信息,请参阅 LICENSE 文件。