Skip to content
This repository has been archived by the owner on Jul 21, 2020. It is now read-only.

Commit

Permalink
Rename tetris -> interactive
Browse files Browse the repository at this point in the history
  • Loading branch information
jackcook committed Aug 17, 2016
1 parent 856a5dd commit 7520b68
Show file tree
Hide file tree
Showing 26 changed files with 187 additions and 187 deletions.
4 changes: 2 additions & 2 deletions BeamAPI.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "BeamAPI"
s.version = "1.1.1"
s.version = "1.2"
s.summary = "An interface to communicate with Beam's backend."
s.homepage = "https://github.com/WatchBeam/beam-client-swift"
s.license = "MIT"
Expand All @@ -9,7 +9,7 @@ Pod::Spec.new do |s|
s.requires_arc = true
s.ios.deployment_target = "8.2"
s.tvos.deployment_target = "9.0"
s.source = { :git => "https://github.com/WatchBeam/beam-client-swift.git", :tag => "1.1.1" }
s.source = { :git => "https://github.com/WatchBeam/beam-client-swift.git", :tag => "1.2" }
s.source_files = "Pod/Classes/**/*"

s.dependency "Starscream", "~> 1.1"
Expand Down
16 changes: 8 additions & 8 deletions Example/BeamAPI.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
EB4A0EDB1C5D239A0012693F /* ShopTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = EB4A0EDA1C5D239A0012693F /* ShopTests.swift */; };
EB4A0EDD1C5D25B40012693F /* UsersTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = EB4A0EDC1C5D25B40012693F /* UsersTests.swift */; };
EB4A0EE21C5D33AB0012693F /* ChatClientTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = EB4A0EE11C5D33AB0012693F /* ChatClientTests.swift */; };
EB9890B41C88F9FB0080A4E9 /* TetrisTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = EB9890B31C88F9FB0080A4E9 /* TetrisTests.swift */; };
EB9890B41C88F9FB0080A4E9 /* InteractiveTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = EB9890B31C88F9FB0080A4E9 /* InteractiveTests.swift */; };
EB9B4CEE1D5A42F700BD817B /* NotificationsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = EB9B4CED1D5A42F700BD817B /* NotificationsTests.swift */; };
EBA92A8B1C8B53B3008F3A7F /* TetrisClientTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = EBA92A8A1C8B53B3008F3A7F /* TetrisClientTests.swift */; };
EBA92A8B1C8B53B3008F3A7F /* InteractiveClientTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = EBA92A8A1C8B53B3008F3A7F /* InteractiveClientTests.swift */; };
EBF068781C5D3684007ACCF9 /* SessionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = EBF068771C5D3684007ACCF9 /* SessionTests.swift */; };
EBF865771D35A725001EE937 /* IngestsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = EBF865761D35A725001EE937 /* IngestsTests.swift */; };
EBF865791D35A77E001EE937 /* RecordingsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = EBF865781D35A77E001EE937 /* RecordingsTests.swift */; };
Expand All @@ -45,9 +45,9 @@
EB4A0EDA1C5D239A0012693F /* ShopTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ShopTests.swift; sourceTree = "<group>"; };
EB4A0EDC1C5D25B40012693F /* UsersTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UsersTests.swift; sourceTree = "<group>"; };
EB4A0EE11C5D33AB0012693F /* ChatClientTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ChatClientTests.swift; sourceTree = "<group>"; };
EB9890B31C88F9FB0080A4E9 /* TetrisTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TetrisTests.swift; sourceTree = "<group>"; };
EB9890B31C88F9FB0080A4E9 /* InteractiveTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = InteractiveTests.swift; sourceTree = "<group>"; };
EB9B4CED1D5A42F700BD817B /* NotificationsTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NotificationsTests.swift; sourceTree = "<group>"; };
EBA92A8A1C8B53B3008F3A7F /* TetrisClientTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TetrisClientTests.swift; sourceTree = "<group>"; };
EBA92A8A1C8B53B3008F3A7F /* InteractiveClientTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = InteractiveClientTests.swift; sourceTree = "<group>"; };
EBF068771C5D3684007ACCF9 /* SessionTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SessionTests.swift; sourceTree = "<group>"; };
EBF865761D35A725001EE937 /* IngestsTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = IngestsTests.swift; sourceTree = "<group>"; };
EBF865781D35A77E001EE937 /* RecordingsTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RecordingsTests.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -136,12 +136,12 @@
EB4A0ED61C5D1B310012693F /* ChannelsTests.swift */,
EB4A0ED81C5D1CEE0012693F /* ChatTests.swift */,
EBF865761D35A725001EE937 /* IngestsTests.swift */,
EB9890B31C88F9FB0080A4E9 /* InteractiveTests.swift */,
EB9B4CED1D5A42F700BD817B /* NotificationsTests.swift */,
EB1207561D381A1C00365126 /* OAuthTests.swift */,
EBF865781D35A77E001EE937 /* RecordingsTests.swift */,
EB4A0EDA1C5D239A0012693F /* ShopTests.swift */,
EB06F6B51D36DA410019024F /* TeamsTests.swift */,
EB9890B31C88F9FB0080A4E9 /* TetrisTests.swift */,
EB3FD0371D394EC000964ECA /* TypesTests.swift */,
EB4A0EDC1C5D25B40012693F /* UsersTests.swift */,
);
Expand All @@ -153,8 +153,8 @@
children = (
EB4A0EE11C5D33AB0012693F /* ChatClientTests.swift */,
EB35BDD91D5B9FC90089A82E /* ConstellationClientTests.swift */,
EBA92A8A1C8B53B3008F3A7F /* InteractiveClientTests.swift */,
EBF068771C5D3684007ACCF9 /* SessionTests.swift */,
EBA92A8A1C8B53B3008F3A7F /* TetrisClientTests.swift */,
);
name = Clients;
sourceTree = "<group>";
Expand Down Expand Up @@ -279,13 +279,13 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
EBA92A8B1C8B53B3008F3A7F /* TetrisClientTests.swift in Sources */,
EBA92A8B1C8B53B3008F3A7F /* InteractiveClientTests.swift in Sources */,
EB1207571D381A1C00365126 /* OAuthTests.swift in Sources */,
EB4A0EE21C5D33AB0012693F /* ChatClientTests.swift in Sources */,
EB4A0ED71C5D1B310012693F /* ChannelsTests.swift in Sources */,
EBF865771D35A725001EE937 /* IngestsTests.swift in Sources */,
EB06F6B61D36DA410019024F /* TeamsTests.swift in Sources */,
EB9890B41C88F9FB0080A4E9 /* TetrisTests.swift in Sources */,
EB9890B41C88F9FB0080A4E9 /* InteractiveTests.swift in Sources */,
EBF068781C5D3684007ACCF9 /* SessionTests.swift in Sources */,
EB4A0ED91C5D1CEE0012693F /* ChatTests.swift in Sources */,
EB3FD0381D394EC000964ECA /* TypesTests.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// TetrisClientTests.swift
// InteractiveClientTests.swift
// BeamAPI
//
// Created by Jack Cook on 3/5/16.
Expand All @@ -9,11 +9,11 @@
import BeamAPI
import XCTest

class TetrisClientTests: XCTestCase, TetrisClientDelegate {
class InteractiveClientTests: XCTestCase, InteractiveClientDelegate {

var address: String!
var channel: BeamChannel!
var client: TetrisClient!
var client: InteractiveClient!
var expectation: XCTestExpectation!

override func setUp() {
Expand All @@ -31,7 +31,7 @@ class TetrisClientTests: XCTestCase, TetrisClientDelegate {

self.channel = channel

BeamClient.sharedClient.tetris.getTetrisDataByChannel(self.channel.id) { (data, error) in
BeamClient.sharedClient.Interactive.getInteractiveDataByChannel(self.channel.id) { (data, error) in
guard let address = data?.address else {
XCTFail()
return
Expand All @@ -47,22 +47,22 @@ class TetrisClientTests: XCTestCase, TetrisClientDelegate {
}

func testConnect() {
expectation = expectationWithDescription("test joining a channel through tetris")
expectation = expectationWithDescription("test joining a channel through Interactive")

client = TetrisClient(delegate: self)
client = InteractiveClient(delegate: self)
client.connect(url: address, channelId: channel.id)

waitForExpectationsWithTimeout(10, handler: nil)
}

func tetrisDidConnect() {
func InteractiveDidConnect() {
client.disconnect()
}

func tetrisDidDisconnect() {
func InteractiveDidDisconnect() {
expectation.fulfill()
}

func tetrisChangedState(state: String) {}
func tetrisReceivedPacket(packet: TetrisPacket) {}
func InteractiveChangedState(state: String) {}
func InteractiveReceivedPacket(packet: InteractivePacket) {}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// TetrisTests.swift
// InteractiveTests.swift
// BeamAPI
//
// Created by Jack Cook on 3/3/16.
Expand All @@ -9,14 +9,14 @@
import BeamAPI
import XCTest

class TetrisTests: XCTestCase {
class InteractiveTests: XCTestCase {

let channelId = 50772

func testTetrisData() {
let expectation = expectationWithDescription("tests the tetris data endpoint")
func testInteractiveData() {
let expectation = expectationWithDescription("tests the Interactive data endpoint")

BeamClient.sharedClient.tetris.getTetrisDataByChannel(channelId) { (data, error) in
BeamClient.sharedClient.Interactive.getInteractiveDataByChannel(channelId) { (data, error) in
XCTAssertNotNil(data)
XCTAssertNil(error)
expectation.fulfill()
Expand Down
6 changes: 3 additions & 3 deletions Pod/Classes/Clients/BeamClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ public class BeamClient {
/// The property through which all team methods are accessed.
public let teams: TeamsRoutes

/// The property through which all tetris methods are accessed.
public let tetris: TetrisRoutes
/// The property through which all Interactive methods are accessed.
public let Interactive: InteractiveRoutes

/// The property through which all type methods are accessed.
public let types: TypesRoutes
Expand All @@ -64,7 +64,7 @@ public class BeamClient {
recordings = RecordingsRoutes()
shop = ShopRoutes()
teams = TeamsRoutes()
tetris = TetrisRoutes()
Interactive = InteractiveRoutes()
types = TypesRoutes()
users = UsersRoutes()
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// TetrisClient.swift
// InteractiveClient.swift
// Pods
//
// Created by Jack Cook on 3/5/16.
Expand All @@ -9,13 +9,13 @@
import Starscream
import SwiftyJSON

/// Used to connect to a channel's interactive controls through our tetris protocol.
public class TetrisClient: WebSocketDelegate {
/// Used to connect to a channel's interactive controls through our Interactive protocol.
public class InteractiveClient: WebSocketDelegate {

// MARK: Properties

/// The client's delegate, through which control updates are relayed to your app.
private weak var delegate: TetrisClientDelegate?
private weak var delegate: InteractiveClientDelegate?

/// The stored authentication key. Will only be generated if BeamSession.sharedSession != nil, and is needed to send control updates.
private var authKey: String?
Expand All @@ -26,25 +26,25 @@ public class TetrisClient: WebSocketDelegate {
/// The id of the authenticated user in the app.
private var userId: Int?

/// The current tetris control state.
/// The current Interactive control state.
private var state: String?

/// The websocket through which control updates are received and sent.
private var socket: WebSocket?

/// Initializes a tetris connection, which needs to be stored by your own class.
public init(delegate tetrisDelegate: TetrisClientDelegate) {
delegate = tetrisDelegate
/// Initializes a Interactive connection, which needs to be stored by your own class.
public init(delegate InteractiveDelegate: InteractiveClientDelegate) {
delegate = InteractiveDelegate
}

// MARK: Public Methods

/**
Connects to a tetris channel given data that is received with TetrisRoutes.getTetrisDataByChannel
Connects to a Interactive channel given data that is received with InteractiveRoutes.getInteractiveDataByChannel

:param: url The base URL of the tetris server being connected to.
:param: url The base URL of the Interactive server being connected to.
:param: channelId The id of the channel being connected to.
:param: key The key used to authenticate with tetris.
:param: key The key used to authenticate with Interactive.
:param: userId The id of the authenticated user in the app.
*/
public func connect(url baseUrl: String, channelId: Int, key: String? = nil, userId: Int? = nil) {
Expand All @@ -61,22 +61,22 @@ public class TetrisClient: WebSocketDelegate {
socket?.connect()
}

/// Disconnects from the tetris server.
/// Disconnects from the Interactive server.
public func disconnect() {
self.socket?.disconnect()
}

/**
Sends a packet to the tetris server.
Sends a packet to the Interactive server.

:param: packet The packet being sent.
*/
public func sendPacket(packet: TetrisSendable) {
public func sendPacket(packet: InteractiveSendable) {
guard let socket = socket else {
return
}

let packetData = TetrisPacket.prepareToSend(packet)
let packetData = InteractivePacket.prepareToSend(packet)
socket.writeString(packetData)
}

Expand All @@ -86,35 +86,35 @@ public class TetrisClient: WebSocketDelegate {
private func updateState(state: String) {
if state != self.state {
self.state = state
delegate?.tetrisChangedState(state)
delegate?.InteractiveChangedState(state)
}
}

// MARK: WebSocketDelegate

public func websocketDidConnect(socket: WebSocket) {
delegate?.tetrisDidConnect()
delegate?.InteractiveDidConnect()

guard let authKey = authKey,
userId = userId else {
let packet = TetrisHandshakePacket()
let packet = InteractiveHandshakePacket()
sendPacket(packet)

return
}

let packet = TetrisHandshakePacket(id: userId, key: authKey)
let packet = InteractiveHandshakePacket(id: userId, key: authKey)
sendPacket(packet)
}

public func websocketDidDisconnect(socket: WebSocket, error: NSError?) {
delegate?.tetrisDidDisconnect()
delegate?.InteractiveDidDisconnect()
}

public func websocketDidReceiveMessage(socket: WebSocket, text: String) {
if let (packet, state) = TetrisPacket.receivePacket(text) {
if let (packet, state) = InteractivePacket.receivePacket(text) {
if let packet = packet {
delegate?.tetrisReceivedPacket(packet)
delegate?.InteractiveReceivedPacket(packet)
}

if let state = state {
Expand All @@ -127,18 +127,18 @@ public class TetrisClient: WebSocketDelegate {
}
}

/// The tetris client's delegate, through which information is relayed to your app.
public protocol TetrisClientDelegate: class {
/// The Interactive client's delegate, through which information is relayed to your app.
public protocol InteractiveClientDelegate: class {

/// Called when a connection is made to the tetris server.
func tetrisDidConnect()
/// Called when a connection is made to the Interactive server.
func InteractiveDidConnect()

/// Called when the client disconnects, whether on purpose or due to an error.
func tetrisDidDisconnect()
func InteractiveDidDisconnect()

/// Called when the control state is changed by the broadcaster.
func tetrisChangedState(state: String)
func InteractiveChangedState(state: String)

/// Called when a packet is received and interpreted.
func tetrisReceivedPacket(packet: TetrisPacket)
func InteractiveReceivedPacket(packet: InteractivePacket)
}
6 changes: 3 additions & 3 deletions Pod/Classes/Models/BeamChannel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ public struct BeamChannel {
/// True if the channel's content is interactive.
public let interactive: Bool

/// The id of the tetris game being used by the channel.
public let tetrisGameId: Int?
/// The id of the Interactive game being used by the channel.
public let InteractiveGameId: Int?

/// FTL is enabled if this value is > 0.
public let ftl: Int
Expand Down Expand Up @@ -163,7 +163,7 @@ public struct BeamChannel {
desc = json["description"].string
typeId = json["typeId"].int
interactive = json["interactive"].bool ?? (json["interactive"].int ?? 0) == 1
tetrisGameId = json["tetrisGameId"].int
InteractiveGameId = json["InteractiveGameId"].int
ftl = json["ftl"].int ?? 0
hasVod = json["hasVod"].bool ?? false
createdAt = NSDate.fromBeam(json["createdAt"].string)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// TetrisBlueprint.swift
// InteractiveBlueprint.swift
// Pods
//
// Created by Jack Cook on 2/27/16.
Expand All @@ -9,18 +9,18 @@
import SwiftyJSON

/// A control's set of configurations for certain states and grid sizes.
public struct TetrisBlueprint {
public struct InteractiveBlueprint {

/// The possible configurations in the control's blueprint.
public var configurations: [TetrisBlueprintConfiguration]
public var configurations: [InteractiveBlueprintConfiguration]

/// Used to initialize a blueprint given JSON data.
init(json: JSON) {
self.configurations = [TetrisBlueprintConfiguration]()
self.configurations = [InteractiveBlueprintConfiguration]()

if let configurations = json.array {
for configurationData in configurations {
let configuration = TetrisBlueprintConfiguration(json: configurationData)
let configuration = InteractiveBlueprintConfiguration(json: configurationData)
self.configurations.append(configuration)
}
}
Expand Down
Loading

0 comments on commit 7520b68

Please sign in to comment.