Session
in package
Table of Contents
Constants
- TIME_BEFORE_EXPIRY = 172800
- URL_LOAD_DELAY = [\Smr\Pages\Player\HardwareConfigure::class => 0.4, \Smr\Pages\Player\ForcesDrop::class => 0.4, \Smr\Pages\Player\ForcesDropProcessor::class => 0.5, \Smr\Pages\Player\ForcesRefreshProcessor::class => 0.4, \Smr\Pages\Player\SectorJumpProcessor::class => 0.4, \Smr\Pages\Player\SectorMoveProcessor::class => 0.4, \Smr\Pages\Player\SectorScan::class => 0.4, \Smr\Pages\Player\ShopGoodsProcessor::class => 0.4, \Smr\Pages\Player\AttackPlayerProcessor::class => 0.75, \Smr\Pages\Player\ExamineTrader::class => 0.75]
Properties
- $ajax : bool
- $ajaxReturns : array<string, string>
- $previousAjaxReturns : array<string, string>|null
- $accountID : int
- $currentPage : Page|null
- $gameID : int
- $generate : bool
- $lastAccessed : float
- $lastSN : string
- $links : array<string, Page>
- $requestData : array<string, mixed>
- $sessionID : string
- $SN : string
Methods
- __construct() : mixed
- Smr\Session constructor.
- addAjaxReturns() : bool
- addLink() : string
- Add a page to the session so that it can be used on next page load.
- clearLinks() : void
- destroy() : void
- fetchVarInfo() : void
- getAccount() : Account
- getAccountID() : int
- getCurrentVar() : Page
- Returns the session var associated with the current SN.
- getGameID() : int
- Returns the Game ID associated with the session.
- getInstance() : self
- Return the Smr\Session in the DI container.
- getLastAccessed() : float
- getPlayer() : AbstractPlayer
- getRequestData() : array<string, mixed>
- getRequestVar() : string
- Gets a var from $var, $_REQUEST, or $default. Then stores it in the session so that it can still be retrieved when the page auto-refreshes.
- getRequestVarInt() : int
- getRequestVarIntArray() : array<int, int>
- getSessionID() : string
- Uniquely identifies the session in the database.
- getSN() : string
- The SN is the URL parameter that defines the page being requested.
- hasAccount() : bool
- hasChangedSN() : bool
- Returns true if the current SN is different than the previous SN.
- hasCurrentVar() : bool
- Check if the session has a var associated with the current SN.
- hasGame() : bool
- Returns true if the session is inside a game, false otherwise.
- saveAjaxReturns() : void
- setAccount() : void
- Sets the `accountID` attribute of this session.
- setCurrentVar() : void
- Replace the global $var with the given $container.
- update() : void
- updateGame() : void
- Updates the `gameID` attribute of the session and deletes any other active sessions in this game for this account.
Constants
TIME_BEFORE_EXPIRY
private
mixed
TIME_BEFORE_EXPIRY
= 172800
URL_LOAD_DELAY
private
mixed
URL_LOAD_DELAY
= [\Smr\Pages\Player\HardwareConfigure::class => 0.4, \Smr\Pages\Player\ForcesDrop::class => 0.4, \Smr\Pages\Player\ForcesDropProcessor::class => 0.5, \Smr\Pages\Player\ForcesRefreshProcessor::class => 0.4, \Smr\Pages\Player\SectorJumpProcessor::class => 0.4, \Smr\Pages\Player\SectorMoveProcessor::class => 0.4, \Smr\Pages\Player\SectorScan::class => 0.4, \Smr\Pages\Player\ShopGoodsProcessor::class => 0.4, \Smr\Pages\Player\AttackPlayerProcessor::class => 0.75, \Smr\Pages\Player\ExamineTrader::class => 0.75]
Properties
$ajax read-only
public
bool
$ajax
$ajaxReturns
protected
array<string, string>
$ajaxReturns
= []
$previousAjaxReturns
protected
array<string, string>|null
$previousAjaxReturns
$accountID
private
int
$accountID
$currentPage
private
Page|null
$currentPage
= null
$gameID
private
int
$gameID
$generate
private
bool
$generate
$lastAccessed
private
float
$lastAccessed
$lastSN
private
string
$lastSN
$links
private
array<string, Page>
$links
= []
$requestData
private
array<string, mixed>
$requestData
= []
$sessionID
private
string
$sessionID
$SN read-only
private
string
$SN
Methods
__construct()
Smr\Session constructor.
public
__construct() : mixed
Not intended to be constructed by hand. Use Smr\Session::getInstance().
addAjaxReturns()
public
addAjaxReturns(string $element, string $contents) : bool
Parameters
- $element : string
- $contents : string
Return values
booladdLink()
Add a page to the session so that it can be used on next page load.
public
addLink(Page $container) : string
It will be associated with an SN that will be used for linking.
Parameters
- $container : Page
Return values
stringclearLinks()
public
clearLinks() : void
destroy()
public
destroy() : void
fetchVarInfo()
public
fetchVarInfo() : void
getAccount()
public
getAccount() : Account
Return values
AccountgetAccountID()
public
getAccountID() : int
Return values
intgetCurrentVar()
Returns the session var associated with the current SN.
public
getCurrentVar() : Page
Return values
PagegetGameID()
Returns the Game ID associated with the session.
public
getGameID() : int
Return values
intgetInstance()
Return the Smr\Session in the DI container.
public
static getInstance() : self
If one does not exist yet, it will be created. This is the intended way to construct this class.
Return values
selfgetLastAccessed()
public
getLastAccessed() : float
Return values
floatgetPlayer()
public
getPlayer([bool $forceUpdate = false ]) : AbstractPlayer
Parameters
- $forceUpdate : bool = false
Return values
AbstractPlayergetRequestData()
public
getRequestData() : array<string, mixed>
Return values
array<string, mixed>getRequestVar()
Gets a var from $var, $_REQUEST, or $default. Then stores it in the session so that it can still be retrieved when the page auto-refreshes.
public
getRequestVar(string $varName[, string|null $default = null ]) : string
This is the recommended way to get $_REQUEST data for display pages. For processing pages, see the Request class.
Parameters
- $varName : string
- $default : string|null = null
Return values
stringgetRequestVarInt()
public
getRequestVarInt(string $varName[, int|null $default = null ]) : int
Parameters
- $varName : string
- $default : int|null = null
Return values
intgetRequestVarIntArray()
public
getRequestVarIntArray(string $varName[, array<int, int>|null $default = null ]) : array<int, int>
Parameters
- $varName : string
- $default : array<int, int>|null = null
Return values
array<int, int>getSessionID()
Uniquely identifies the session in the database.
public
getSessionID() : string
Return values
stringgetSN()
The SN is the URL parameter that defines the page being requested.
public
getSN() : string
Return values
stringhasAccount()
public
hasAccount() : bool
Return values
boolhasChangedSN()
Returns true if the current SN is different than the previous SN.
public
hasChangedSN() : bool
Return values
boolhasCurrentVar()
Check if the session has a var associated with the current SN.
public
hasCurrentVar() : bool
Return values
boolhasGame()
Returns true if the session is inside a game, false otherwise.
public
hasGame() : bool
Return values
boolsaveAjaxReturns()
public
saveAjaxReturns() : void
setAccount()
Sets the `accountID` attribute of this session.
public
setAccount(Account $account) : void
Parameters
- $account : Account
setCurrentVar()
Replace the global $var with the given $container.
public
setCurrentVar(Page $container) : void
Parameters
- $container : Page
update()
public
update() : void
updateGame()
Updates the `gameID` attribute of the session and deletes any other active sessions in this game for this account.
public
updateGame(int $gameID) : void
Parameters
- $gameID : int