mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-23 16:23:12 +09:00
Player session end tracking
This commit is contained in:
1 parent
2eedddf17f
commit
73ab8fc4f3
5 files changed
+288
-3
No files matched your search
@@ -56,6 +56,13 @@ export const PlayerDataSchema = Type.Object({
|
||||
|
||||
export type PlayerData = Static<typeof PlayerDataSchema>;
|
||||
|
||||
export const PlayerSessionEndDataSchema = Type.Object({
|
||||
player_name: Type.String(),
|
||||
surface: Type.String(),
|
||||
});
|
||||
|
||||
export type PlayerSessionEndData = Static<typeof PlayerSessionEndDataSchema>;
|
||||
|
||||
/**
|
||||
* PlayerPositionEvent: Used for both Factorio Instance -> Controller and Controller -> Web Clients
|
||||
*
|
||||
@@ -93,6 +100,37 @@ export class PlayerPositionEvent {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* PlayerSessionEndEvent: Instance -> Controller
|
||||
*
|
||||
* Notifies controller that a player session has ended (disconnect).
|
||||
*/
|
||||
export class PlayerSessionEndEvent {
|
||||
declare ["constructor"]: typeof PlayerSessionEndEvent;
|
||||
static type = "event" as const;
|
||||
static src = ["instance"] as const;
|
||||
static dst = ["controller"] as const;
|
||||
static plugin = "minimap" as const;
|
||||
static permission = null;
|
||||
|
||||
constructor(
|
||||
public instance_id: number,
|
||||
public session_data: PlayerSessionEndData,
|
||||
) { }
|
||||
|
||||
static jsonSchema = Type.Object({
|
||||
"instance_id": Type.Number(),
|
||||
"session_data": PlayerSessionEndDataSchema,
|
||||
});
|
||||
|
||||
static fromJSON(json: Static<typeof PlayerSessionEndEvent.jsonSchema>) {
|
||||
return new this(
|
||||
json.instance_id,
|
||||
json.session_data
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* TileDataEvent: Used for both Factorio Instance -> Controller and Controller -> Web Clients
|
||||
*
|
||||
|
||||
Reference in new issue
Block a user