BeamAPI 1.5.7

BeamAPI 1.5.7

测试经过测试
Lang语言 SwiftSwift
许可证 MIT
发布最后发布2017年5月
SwiftSwift 版本3.0
SPM支持 SPM

Jack Cook 维护。



 
依赖
Starscream~> 2.0
SwiftyJSON~> 3.1
 

BeamAPI 1.5.7

  • 作者
  • Jack Cook

BeamAPI

这是一个用 Swift 编写的 Beam 客户端库。

特性

  • 使用 Beam 认证并管理用户会话
  • 检索有关频道、用户和其他资源的完整数据
  • 通过聊天和交互服务器发送和接收数据包
  • 完整文档

使用方法

要运行示例项目,首先克隆仓库,然后在 Example 目录中运行 pod install

需求

  • iOS 8.2+ / tvOS 9.0+ (macOS 和 watchOS 将很快推出)
  • Xcode 7.3+

使用方法

获取频道数据

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 文件。