TestsTested | ✓ |
LangLanguage | SwiftSwift |
License | MIT |
ReleasedLast Release | May 2017 |
SwiftSwift Version | 3.0 |
SPMSupports SPM | ✓ |
Maintained by Jack Cook.
Depends on: | |
Starscream | ~> 2.0 |
SwiftyJSON | ~> 3.1 |
This is a client library for Beam written in Swift.
To run the example project, clone the repo, and run pod install
from the Example directory first.
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 is available under the MIT license. See the LICENSE file for more info.