mud_server.db.sessions_repo

Session repository operations for the SQLite backend.

This module owns account/in-world session persistence while preserving current runtime behavior expected by API, engine, and tests.

Functions

create_session(user_id, session_id, *[, client_type, ...])

Create account-only or character-bound session row.

set_session_character(session_id, character_id, *, ...)

Bind character and explicit world to an existing session row.

remove_session_by_id(session_id)

Remove one session by its session token.

remove_sessions_for_user(user_id)

Remove all sessions for user id.

remove_sessions_for_character(character_id)

Remove all sessions bound to character id.

remove_sessions_for_character_count(character_id)

Remove all sessions for character id and return removed row count.

update_session_activity(session_id)

Update last activity and apply sliding expiration if configured.

get_session_by_id(session_id)

Return session record by token, or None if absent.

get_active_session_count()

Count active sessions within the configured activity window.

cleanup_expired_sessions()

Delete expired session rows and return number removed.

clear_all_sessions()

Delete all session rows and return number removed.

get_active_characters(*, world_id)

Return active character names for one explicit world scope.

Module Contents

mud_server.db.sessions_repo.create_session(user_id, session_id, *, client_type='unknown', character_id=None, world_id=None)[source]

Create account-only or character-bound session row.

Behavior mirrors the compatibility facade contract: - if user_id is str, resolve by username; - when character_id is provided and world_id omitted, world is

derived from the character row;

  • account-only sessions enforce world_id = NULL.

mud_server.db.sessions_repo.set_session_character(session_id, character_id, *, world_id)[source]

Bind character and explicit world to an existing session row.

mud_server.db.sessions_repo.remove_session_by_id(session_id)[source]

Remove one session by its session token.

mud_server.db.sessions_repo.remove_sessions_for_user(user_id)[source]

Remove all sessions for user id.

mud_server.db.sessions_repo.remove_sessions_for_character(character_id)[source]

Remove all sessions bound to character id.

mud_server.db.sessions_repo.remove_sessions_for_character_count(character_id)[source]

Remove all sessions for character id and return removed row count.

mud_server.db.sessions_repo.update_session_activity(session_id)[source]

Update last activity and apply sliding expiration if configured.

mud_server.db.sessions_repo.get_session_by_id(session_id)[source]

Return session record by token, or None if absent.

mud_server.db.sessions_repo.get_active_session_count()[source]

Count active sessions within the configured activity window.

mud_server.db.sessions_repo.cleanup_expired_sessions()[source]

Delete expired session rows and return number removed.

mud_server.db.sessions_repo.clear_all_sessions()[source]

Delete all session rows and return number removed.

mud_server.db.sessions_repo.get_active_characters(*, world_id)[source]

Return active character names for one explicit world scope.