Encapsulate session handling from protocol to new SessionManager (#247)
This commit is contained in:
parent
a6ed01bec0
commit
ae320646bf
1 changed files with 444 additions and 200 deletions
47
src/Server/Session/SessionManagerInterface.php
Normal file
47
src/Server/Session/SessionManagerInterface.php
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the official PHP MCP SDK.
|
||||
*
|
||||
* A collaboration between Symfony and the PHP Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Mcp\Server\Session;
|
||||
|
||||
use Symfony\Component\Uid\Uuid;
|
||||
|
||||
/**
|
||||
* Factory interface for creating session instances.
|
||||
* This allows for different session implementations and custom initialization logic.
|
||||
*
|
||||
* @author Kyrian Obikwelu <koshnawaza@gmail.com>
|
||||
*/
|
||||
interface SessionManagerInterface
|
||||
{
|
||||
/**
|
||||
* Creates a new session with an auto-generated UUID.
|
||||
* This is the standard factory method for creating sessions.
|
||||
*/
|
||||
public function create(): SessionInterface;
|
||||
|
||||
/**
|
||||
* Creates a session with a specific UUID.
|
||||
* Use this when you need to reconstruct a session with a known ID.
|
||||
*/
|
||||
public function createWithId(Uuid $id): SessionInterface;
|
||||
|
||||
/**
|
||||
* Checks if a session with the given UUID exists.
|
||||
*/
|
||||
public function exists(Uuid $id): bool;
|
||||
|
||||
/**
|
||||
* Destroys the session with the given UUID.
|
||||
*/
|
||||
public function destroy(Uuid $id): bool;
|
||||
|
||||
public function gc(): void;
|
||||
}
|
||||
Loading…
Reference in a new issue