logo SERENITY
Game Systems Foundation
Search Results for

    Show / Hide Table of Contents

    Interface IGameSessionService

    Service interface for managing the global runtime state of a game session.

    Namespace: Serenity.GameSession.Application.Interfaces
    Assembly: Serenity.GameSession.Application.dll
    Syntax
    public interface IGameSessionService : IService, IFoundationSettings
    Remarks

    GameSession is a coordination aggregate, not a rules engine. It centralizes session-wide state (status, elapsed time, score) to avoid duplication across systems. Game rules and win/lose conditions are handled externally.

    Properties

    ElapsedTime

    Gets the total elapsed game time in seconds.

    Declaration
    float ElapsedTime { get; }
    Property Value
    Type Description
    float

    SessionId

    Gets the current session identity.

    Declaration
    GameSessionId SessionId { get; }
    Property Value
    Type Description
    GameSessionId

    Status

    Gets the current session status.

    Declaration
    GameSessionStatus Status { get; }
    Property Value
    Type Description
    GameSessionStatus

    Methods

    Complete()

    Ends the session with a completion condition.

    Declaration
    void Complete()

    ConfigureTimer(ITimer)

    Configures the timer used to track session elapsed time.
    Must be called before StartSession(GameSessionId). The service takes ownership of the timer lifecycle (initialize, start, stop).

    Declaration
    void ConfigureTimer(ITimer timer)
    Parameters
    Type Name Description
    ITimer timer

    The timer instance registered for this session.

    GameOver()

    Ends the session with a game-over condition.

    Declaration
    void GameOver()

    GetSnapshot()

    Returns an immutable snapshot of the current session state.

    Declaration
    GameSessionSnapshot GetSnapshot()
    Returns
    Type Description
    GameSessionSnapshot

    A GameSessionSnapshot of the session.

    Pause()

    Pauses the current session.

    Declaration
    void Pause()

    Resume()

    Resumes the current session from a paused state.

    Declaration
    void Resume()

    StartSession(GameSessionId)

    Starts a new session with the specified identity.

    Declaration
    void StartSession(GameSessionId sessionId)
    Parameters
    Type Name Description
    GameSessionId sessionId

    The session identity.

    Tick()

    Updates the session state (e.g. elapsed time). Called per frame or tick.

    Declaration
    void Tick()
    In this article
    © 2026 Serenity. All Rights Reserved