-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
28 changed files
with
2,106 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
.DS_Store | ||
/.build | ||
/Packages | ||
xcuserdata/ | ||
DerivedData/ | ||
.swiftpm/configuration/registries.json | ||
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata | ||
.netrc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2017 Alejandro Alonso | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// swift-tools-version: 5.9 | ||
// The swift-tools-version declares the minimum version of Swift required to build this package. | ||
|
||
import PackageDescription | ||
|
||
let package = Package( | ||
name: "SwordRPC", | ||
products: [ | ||
// Products define the executables and libraries a package produces, making them visible to other packages. | ||
.library( | ||
name: "SwordRPC", | ||
targets: ["SwordRPC"]), | ||
], | ||
dependencies: [ | ||
.package(url: "https://github.com/Kitura/BlueSocket", from: "2.0.0") | ||
], | ||
targets: [ | ||
.target( | ||
name: "SwordRPC", | ||
dependencies: [ | ||
.product(name: "Socket", package: "BlueSocket") | ||
] | ||
) | ||
] | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
// | ||
// Delegate.swift | ||
// SwordRPC | ||
// | ||
// Created by Alejandro Alonso | ||
// Copyright © 2017 Alejandro Alonso. All rights reserved. | ||
// | ||
|
||
public protocol SwordRPCDelegate: AnyObject { | ||
func swordRPCDidConnect( | ||
_ rpc: SwordRPC | ||
) | ||
|
||
func swordRPCDidDisconnect( | ||
_ rpc: SwordRPC, | ||
code: Int?, | ||
message msg: String? | ||
) | ||
|
||
func swordRPCDidReceiveError( | ||
_ rpc: SwordRPC, | ||
code: Int, | ||
message msg: String | ||
) | ||
|
||
func swordRPCDidJoinGame( | ||
_ rpc: SwordRPC, | ||
secret: String | ||
) | ||
|
||
func swordRPCDidSpectateGame( | ||
_ rpc: SwordRPC, | ||
secret: String | ||
) | ||
|
||
func swordRPCDidReceiveJoinRequest( | ||
_ rpc: SwordRPC, | ||
request: JoinRequest, | ||
secret: String | ||
) | ||
} | ||
|
||
extension SwordRPCDelegate { | ||
public func swordRPCDidConnect( | ||
_ rpc: SwordRPC | ||
) {} | ||
|
||
public func swordRPCDidDisconnect( | ||
_ rpc: SwordRPC, | ||
code: Int?, | ||
message msg: String? | ||
) {} | ||
|
||
public func swordRPCDidReceiveError( | ||
_ rpc: SwordRPC, | ||
code: Int, | ||
message msg: String | ||
) {} | ||
|
||
public func swordRPCDidJoinGame( | ||
_ rpc: SwordRPC, | ||
secret: String | ||
) {} | ||
|
||
public func swordRPCDidSpectateGame( | ||
_ rpc: SwordRPC, | ||
secret: String | ||
) {} | ||
|
||
public func swordRPCDidReceiveJoinRequest( | ||
_ rpc: SwordRPC, | ||
request: JoinRequest, | ||
secret: String | ||
) {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// | ||
// Events.swift | ||
// SwordRPC | ||
// | ||
// Created by Alejandro Alonso | ||
// Copyright © 2017 Alejandro Alonso. All rights reserved. | ||
// | ||
|
||
extension SwordRPC { | ||
|
||
public func onConnect( | ||
handler: @escaping (_ rpc: SwordRPC) -> () | ||
) { | ||
self.connectHandler = handler | ||
} | ||
|
||
public func onDisconnect( | ||
handler: @escaping (_ rpc: SwordRPC, _ code: Int?, _ msg: String?) -> () | ||
) { | ||
self.disconnectHandler = handler | ||
} | ||
|
||
public func onError( | ||
handler: @escaping (_ rpc: SwordRPC, _ code: Int, _ msg: String) -> () | ||
) { | ||
self.errorHandler = handler | ||
} | ||
|
||
public func onJoinGame( | ||
handler: @escaping (_ rpc: SwordRPC, _ secret: String) -> () | ||
) { | ||
self.joinGameHandler = handler | ||
} | ||
|
||
public func onSpectateGame( | ||
handler: @escaping (_ rpc: SwordRPC, _ secret: String) -> () | ||
) { | ||
self.spectateGameHandler = handler | ||
} | ||
|
||
public func onJoinRequest( | ||
handler: @escaping (_ rpc: SwordRPC, _ request: JoinRequest, _ secret: String) -> () | ||
) { | ||
self.joinRequestHandler = handler | ||
} | ||
|
||
} |
Oops, something went wrong.