-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Json-rpc error state testing, serialization refactoring and cleanup.
- Loading branch information
Karel Hovorka
committed
Jul 20, 2021
1 parent
bc36290
commit 943660c
Showing
17 changed files
with
254 additions
and
92 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
41 changes: 0 additions & 41 deletions
41
JvmClient/src/commonMain/kotlin/spaceEngineers/transport/JsonRpc.kt
This file was deleted.
Oops, something went wrong.
8 changes: 8 additions & 0 deletions
8
JvmClient/src/commonMain/kotlin/spaceEngineers/transport/jsonrpc/JsonRpcError.kt
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 @@ | ||
package spaceEngineers.transport.jsonrpc | ||
|
||
interface JsonRpcError<T> { | ||
val code: Int | ||
val message: String | ||
val data: T? | ||
} | ||
|
8 changes: 8 additions & 0 deletions
8
JvmClient/src/commonMain/kotlin/spaceEngineers/transport/jsonrpc/JsonRpcResponse.kt
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 @@ | ||
package spaceEngineers.transport.jsonrpc | ||
|
||
interface JsonRpcResponse<T : Any> { | ||
val id: Long? | ||
val jsonrpc: String | ||
val result: T? | ||
val error: JsonRpcError<*>? | ||
} |
17 changes: 17 additions & 0 deletions
17
JvmClient/src/commonMain/kotlin/spaceEngineers/transport/jsonrpc/KotlinJsonRpcError.kt
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,17 @@ | ||
package spaceEngineers.transport.jsonrpc | ||
|
||
import kotlinx.serialization.Contextual | ||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
import kotlinx.serialization.json.JsonElement | ||
|
||
@Serializable | ||
data class KotlinJsonRpcError( | ||
@SerialName("code") | ||
override val code: Int, | ||
@SerialName("message") | ||
override val message: String, | ||
@SerialName("data") | ||
@Contextual | ||
override val data: JsonElement? = null | ||
) : Exception(message), JsonRpcError<JsonElement> |
17 changes: 17 additions & 0 deletions
17
JvmClient/src/commonMain/kotlin/spaceEngineers/transport/jsonrpc/KotlinJsonRpcRequest.kt
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,17 @@ | ||
package spaceEngineers.transport.jsonrpc | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
import kotlinx.serialization.json.JsonElement | ||
|
||
@Serializable | ||
data class KotlinJsonRpcRequest( | ||
@SerialName("id") | ||
val id: Long, | ||
@SerialName("jsonrpc") | ||
val jsonrpc: String = "2.0", | ||
@SerialName("method") | ||
val method: String, | ||
@SerialName("params") | ||
val params: Map<String, JsonElement?> | ||
) |
16 changes: 16 additions & 0 deletions
16
JvmClient/src/commonMain/kotlin/spaceEngineers/transport/jsonrpc/KotlinJsonRpcResponse.kt
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,16 @@ | ||
package spaceEngineers.transport.jsonrpc | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class KotlinJsonRpcResponse<T : Any>( | ||
@SerialName("id") | ||
override val id: Long? = null, | ||
@SerialName("jsonrpc") | ||
override val jsonrpc: String = "2.0", | ||
@SerialName("result") | ||
override val result: T? = null, | ||
@SerialName("error") | ||
override val error: KotlinJsonRpcError? = null | ||
): JsonRpcResponse<T> |
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
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
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
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
Oops, something went wrong.