Skip to content

Commit

Permalink
get xcode data and push to rpc
Browse files Browse the repository at this point in the history
  • Loading branch information
llsc12 committed Mar 13, 2024
1 parent 57ee4e9 commit 1e90ca0
Show file tree
Hide file tree
Showing 28 changed files with 2,106 additions and 98 deletions.
8 changes: 8 additions & 0 deletions SwordRPC/.gitignore
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
21 changes: 21 additions & 0 deletions SwordRPC/LICENSE
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.
25 changes: 25 additions & 0 deletions SwordRPC/Package.swift
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")
]
)
]
)
75 changes: 75 additions & 0 deletions SwordRPC/Sources/SwordRPC/Delegate.swift
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
) {}
}
47 changes: 47 additions & 0 deletions SwordRPC/Sources/SwordRPC/Events.swift
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
}

}
Loading

0 comments on commit 1e90ca0

Please sign in to comment.