-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
General improvements, add GetClients action
- Loading branch information
1 parent
890d746
commit 91445b1
Showing
16 changed files
with
166 additions
and
80 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
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
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
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 |
---|---|---|
@@ -1,28 +1,43 @@ | ||
package spms.server | ||
|
||
import kotlinx.serialization.Serializable | ||
import spms.localisation.Language | ||
|
||
typealias SpMsClientID = Int | ||
|
||
enum class SpMsClientType { | ||
HEADLESS, PLAYER | ||
PLAYER, HEADLESS_PLAYER | ||
} | ||
|
||
@Serializable | ||
data class SpMsClientHandshake( | ||
val name: String, | ||
val type: SpMsClientType, | ||
val language: String? = null | ||
) { | ||
fun getLanguage(): Language = | ||
Language.fromCode(language) ?: Language.default | ||
} | ||
|
||
@Serializable | ||
data class SpMsClientInfo( | ||
val name: String, | ||
val type: SpMsClientType | ||
val type: SpMsClientType, | ||
val language: Language | ||
) | ||
|
||
internal class SpMsClient( | ||
val id_bytes: ByteArray, | ||
val name: String, | ||
val type: SpMsClientType, | ||
val info: SpMsClientInfo, | ||
var event_head: Int | ||
) { | ||
val name: String get() = info.name | ||
val type: SpMsClientType get() = info.type | ||
val language: Language get() = info.language | ||
|
||
val id: SpMsClientID = id_bytes.contentHashCode() | ||
var ready_to_play: Boolean = false | ||
|
||
override fun toString(): String = | ||
"Client(id=$id, name=$name, type=$type, event_head=$event_head)" | ||
"Client(id=$id, name=$name, type=$type, language=$language, event_head=$event_head)" | ||
} |
Oops, something went wrong.