Skip to content

Commit

Permalink
Adding support for checking server status. Updating README.md.
Browse files Browse the repository at this point in the history
  • Loading branch information
TechUnRestricted committed May 5, 2022
1 parent 25bca3f commit 56d1925
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 127 deletions.
6 changes: 2 additions & 4 deletions PSDirectSender.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
E29F5F9A28142BAE00A8EA81 /* ServerLinker.m in Sources */ = {isa = PBXBuildFile; fileRef = E29F5F9928142BAE00A8EA81 /* ServerLinker.m */; };
E29F5F9D28142C4C00A8EA81 /* ConfigurationView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E29F5F9C28142C4C00A8EA81 /* ConfigurationView.swift */; };
E29F5FBA2814367B00A8EA81 /* Networking.swift in Sources */ = {isa = PBXBuildFile; fileRef = E29F5FB92814367B00A8EA81 /* Networking.swift */; };
E29F5FD128143EDC00A8EA81 /* ComboboxView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E29F5FD028143EDC00A8EA81 /* ComboboxView.swift */; };
E2A069F6281AA717001FAFE1 /* ServerStatusView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E2A069F5281AA717001FAFE1 /* ServerStatusView.swift */; };
E2A06A0D281B359D001FAFE1 /* ConnectionDetails.swift in Sources */ = {isa = PBXBuildFile; fileRef = E2A06A0C281B359D001FAFE1 /* ConnectionDetails.swift */; };
E2A06A0F281C3DC4001FAFE1 /* ColorButtonStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = E2A06A0E281C3DC4001FAFE1 /* ColorButtonStyle.swift */; };
Expand All @@ -31,6 +30,7 @@
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
E2100C002824276600F02D9D /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
E2525386281FF89B009055A9 /* JsonSuccess.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JsonSuccess.swift; sourceTree = "<group>"; };
E2525388281FF916009055A9 /* JsonFailure.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JsonFailure.swift; sourceTree = "<group>"; };
E26BC3AE28134D8000D339B7 /* PSDirectSender.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = PSDirectSender.app; sourceTree = BUILT_PRODUCTS_DIR; };
Expand All @@ -49,7 +49,6 @@
E29F5F9B28142BC000A8EA81 /* ServerLinker.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ServerLinker.h; sourceTree = "<group>"; };
E29F5F9C28142C4C00A8EA81 /* ConfigurationView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConfigurationView.swift; sourceTree = "<group>"; };
E29F5FB92814367B00A8EA81 /* Networking.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Networking.swift; sourceTree = "<group>"; };
E29F5FD028143EDC00A8EA81 /* ComboboxView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ComboboxView.swift; sourceTree = "<group>"; };
E2A069F5281AA717001FAFE1 /* ServerStatusView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ServerStatusView.swift; sourceTree = "<group>"; };
E2A06A0B281ADDE8001FAFE1 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
E2A06A0C281B359D001FAFE1 /* ConnectionDetails.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConnectionDetails.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -113,6 +112,7 @@
E26BC3BA28134D8100D339B7 /* PSDirectSender.entitlements */,
E26BC3B728134D8100D339B7 /* Preview Content */,
E2A06A0B281ADDE8001FAFE1 /* Info.plist */,
E2100C002824276600F02D9D /* README.md */,
);
path = PSDirectSender;
sourceTree = "<group>";
Expand Down Expand Up @@ -153,7 +153,6 @@
children = (
E2A069F5281AA717001FAFE1 /* ServerStatusView.swift */,
E26BC3C6281350D500D339B7 /* SidebarButton.swift */,
E29F5FD028143EDC00A8EA81 /* ComboboxView.swift */,
E2A06A0E281C3DC4001FAFE1 /* ColorButtonStyle.swift */,
E286805628204A850036E0C5 /* VisualEffectBlur.swift */,
);
Expand Down Expand Up @@ -259,7 +258,6 @@
E29F5F9A28142BAE00A8EA81 /* ServerLinker.m in Sources */,
E26BC3E52813F85300D339B7 /* mongoose.c in Sources */,
E29F5FBA2814367B00A8EA81 /* Networking.swift in Sources */,
E29F5FD128143EDC00A8EA81 /* ComboboxView.swift in Sources */,
E2A06A0D281B359D001FAFE1 /* ConnectionDetails.swift in Sources */,
E2C028B3281464D1009B94EC /* QueueView.swift in Sources */,
E2A06A11281C5D47001FAFE1 /* LogsView.swift in Sources */,
Expand Down
84 changes: 0 additions & 84 deletions PSDirectSender/Custom Views/ComboboxView.swift

This file was deleted.

39 changes: 19 additions & 20 deletions PSDirectSender/PSDirectSenderApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -231,29 +231,28 @@ func checkIfServerIsWorking(serverIP: String, serverPort: String) -> ServerStatu
guard let url = URL(string: "http://\(serverIP):\(serverPort)") else {
return .fail
}

let config = URLSessionConfiguration.default
config.requestCachePolicy = .reloadIgnoringLocalCacheData
config.urlCache = nil

var status: ServerStatus = .stopped

var request = URLRequest(
url: url,
cachePolicy: .reloadIgnoringLocalCacheData
)
request.httpMethod = "HEAD"
request.timeoutInterval = 3

let semaphore = DispatchSemaphore(value: 0)
let request = URLRequest(url: url, cachePolicy: URLRequest.CachePolicy.reloadIgnoringLocalCacheData, timeoutInterval: 60.0)
URLSession.shared.dataTask(with: request) { (data, response, error) in
if let httpResponse = response as? HTTPURLResponse, let serverHeader = httpResponse.allHeaderFields["Server"] as? String {
if serverHeader == "PSDirectSender/Mongoose"{
status = .success
print("[DEBUG:] \(serverHeader)")
} else {
status = .fail
}
}
semaphore.signal()
}.resume()

semaphore.wait()
let (_/*data*/, response, _/*error*/) = URLSession.shared.synchronousDataTask(with: request)

if let httpResponse = response as? HTTPURLResponse, let serverHeader = httpResponse.allHeaderFields["Server"] as? String {
if serverHeader == "PSDirectSender/Mongoose"{
status = .success
print("[DEBUG:] \(serverHeader)")
} else {
status = .fail
}
} else {
status = .fail
}

return status
}

Expand Down
42 changes: 42 additions & 0 deletions PSDirectSender/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# PSDirectSender
Native **macOS app** for sending **.pkg games** to **PS4** console using **Remote Package Installer**.
Written in Swift, Objective-C and C.

## Current features
* Sending local .pkg files
* Drag'n'drop support
* Creating aliases for files for correct sending .pkg containing spaces in the name.
* Advanced logging system
* Automatic appropriate data generation for the server (IP, Port)

<img width="998" alt="image" src="https://user-images.githubusercontent.com/83237609/166961465-36cb0ac6-00b1-405e-b28a-da6b4b8b6b9e.png">

<details>
<summary><ins>-> more screenshots <-</ins></summary>
<img width="998" alt="image" src="https://user-images.githubusercontent.com/83237609/166961339-b21e1760-7d7c-4874-a4b9-4eb43db63fb1.png">
<img width="998" alt="image" src="https://user-images.githubusercontent.com/83237609/166960997-26f97f01-cb63-40a6-ae71-a16796d588e3.png">
</details>

### To be implemented later
* Resume, pause, stop functionality
* Viewing progress

## System Requirements
* macOS 11.0+
* Apple Silicon / Intel / AMD CPU
* Wired or wireless connection to the same network as PS4
* Local PS4-compatible .pkg files

# Usage
<ol>
<li>Open *PSDirectSender*</li>
<li>Go to the Configuration section</li>
<li>Fill the Console Configuration. (Server configuration should be generated automatically)</li>
<li>Press "Apply settings and Restart Server"</li>
<li>Open Remote Package Installer on PS4</li>
<li>Go to the Queue section</li>
<li>Choose .pkg files from the picker or use the drag'n'drop feature</li>
<li>Press "Send"</li>
</ol>

You can follow the progress from "Notifications" on your PS4
50 changes: 31 additions & 19 deletions PSDirectSender/Screens/ConfigurationView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ This value set by default and should not be changed without special reason.
Points to the port used by the Remote Package Installer application on your console.
"""

}


Expand All @@ -52,8 +52,11 @@ struct ConfigurationView: View {
@StateObject var inputConnectionData: ConnectionDetails = ConnectionDetails()

@StateObject fileprivate var helpShow: HelpShow = HelpShow()
@State var showingAlert: Bool = false;
@State var showingAlert: Bool = false
@State var showingConnectionStatus: Bool = false

@State var alertText: String = ""
@State var connectionStatusLoaded: Bool = false

var body: some View {
ScrollView(.vertical){
Expand Down Expand Up @@ -176,23 +179,32 @@ Staring web server:
}.alert(isPresented: $showingAlert) {
Alert(title: Text("Important message"), message: Text(alertText), dismissButton: .default(Text("Got it!")))
}

/*ServerStatusView(serverStatus: $connection.connectionStatus)
.frame(height: 40)
.onAppear(perform: {
DispatchQueue.global(qos: .background).async {
while(true){
autoreleasepool{
let status = checkIfServerIsWorking(serverIP: connection.serverIP, serverPort: connection.serverPort)
DispatchQueue.main.async {
connection.connectionStatus = status
}
}
sleep(2)

}
}
})*/
Button("Check Server status"){
showingConnectionStatus.toggle()
}.popover(isPresented: $showingConnectionStatus, content: {
VStack{
if !connectionStatusLoaded {
ProgressView()
} else {
ServerStatusView(serverStatus: $connection.connectionStatus)
.frame(height: 40)
}
}
.frame(minWidth: 200)
.padding()
.onAppear(perform: {
connectionStatusLoaded = false

DispatchQueue.global(qos: .background).async {
sleep(1)
let status = checkIfServerIsWorking(serverIP: connection.serverIP, serverPort: connection.serverPort)
DispatchQueue.main.async {
connection.connectionStatus = status
connectionStatusLoaded = true
}
}
})
})
}
}
}
Expand Down

0 comments on commit 56d1925

Please sign in to comment.