mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-20 23:53:13 +09:00
Add version and connect button to player auth
This commit is contained in:
3 files changed
+111
-18
No files matched your search
@@ -1,5 +1,32 @@
|
||||
import { Type, Static } from "@sinclair/typebox";
|
||||
|
||||
export class PlayerAuthServer {
|
||||
declare ["constructor"]: typeof PlayerAuthServer;
|
||||
|
||||
static jsonSchema = Type.Object({
|
||||
name: Type.String(),
|
||||
address: Type.String(),
|
||||
factorioVersion: Type.Optional(Type.String()),
|
||||
});
|
||||
|
||||
constructor(
|
||||
public name: string,
|
||||
public address: string,
|
||||
public factorioVersion?: string,
|
||||
) {}
|
||||
|
||||
toJSON(): Static<typeof PlayerAuthServer.jsonSchema> {
|
||||
if (this.factorioVersion === undefined) {
|
||||
return { name: this.name, address: this.address };
|
||||
}
|
||||
return { name: this.name, address: this.address, factorioVersion: this.factorioVersion };
|
||||
}
|
||||
|
||||
static fromJSON(json: Static<typeof PlayerAuthServer.jsonSchema>) {
|
||||
return new this(json.name, json.address, json.factorioVersion);
|
||||
}
|
||||
}
|
||||
|
||||
class FetchPlayerCodeResponse {
|
||||
constructor(
|
||||
public playerCode: string,
|
||||
|
||||
Reference in new issue
Block a user