Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 0 additions & 87 deletions src/Transport/AbstractTransport.php

This file was deleted.

18 changes: 17 additions & 1 deletion src/Transport/HttpTransport.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
* Origin checks, complex ACK logic, and related session properties have been removed.
* It primarily focuses on basic JSON-RPC via POST.
*/
class HttpTransport extends AbstractTransport
class HttpTransport implements TransportInterface
{
// Kept essential properties for basic POST JSON-RPC.
/** @var ResponseInterface|null The PSR-7 response object being prepared. */
Expand Down Expand Up @@ -266,4 +266,20 @@
}
return $this->response;
}

/**
* Indicates a preference for using Server-Sent Events (SSE) for streaming responses, if applicable.
*
* Transports that support SSE (like HttpTransport) can use this hint to switch
* their response mode. Other transports can ignore this.
*
* @param bool $prefer True to prefer SSE, false otherwise.
*/
public function preferSseStream(bool $prefer = true): void

Check warning on line 278 in src/Transport/HttpTransport.php

View check run for this annotation

Codecov / codecov/patch

src/Transport/HttpTransport.php#L278

Added line #L278 was not covered by tests
{
// Default implementation does nothing, to be overridden by transports that support SSE.
// In a real HttpTransport that supports SSE, this method would set a flag
// to change response content-type and formatting in the send() method.
// For this simplified version, it remains a no-op.
}

Check warning on line 284 in src/Transport/HttpTransport.php

View check run for this annotation

Codecov / codecov/patch

src/Transport/HttpTransport.php#L284

Added line #L284 was not covered by tests
}
13 changes: 12 additions & 1 deletion src/Transport/StdioTransport.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* Implements a transport using STDIN, STDOUT, and STDERR for line-based JSON messaging.
* Each JSON-RPC message (or batch of messages) is expected to be on a single line.
*/
class StdioTransport extends AbstractTransport
class StdioTransport implements TransportInterface
{
/** @var resource The standard input stream. */
private $stdin;
Expand Down Expand Up @@ -203,4 +203,15 @@
{
return false;
}

/**
* Indicates a preference for using Server-Sent Events (SSE) for streaming responses, if applicable.
* StdioTransport does not support SSE, so this is a no-op.
*
* @param bool $prefer True to prefer SSE, false otherwise.
*/
public function preferSseStream(bool $prefer = true): void

Check warning on line 213 in src/Transport/StdioTransport.php

View check run for this annotation

Codecov / codecov/patch

src/Transport/StdioTransport.php#L213

Added line #L213 was not covered by tests
{
// StdioTransport does not support SSE.
}

Check warning on line 216 in src/Transport/StdioTransport.php

View check run for this annotation

Codecov / codecov/patch

src/Transport/StdioTransport.php#L216

Added line #L216 was not covered by tests
}
10 changes: 0 additions & 10 deletions src/Transport/TransportInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,6 @@ public function receive(): ?array;
*/
public function send(JsonRpcMessage|array $message): void;

/**
* Logs a message specific to the transport's operation.
*
* Example: For StdioTransport, this might write to STDERR.
* For HttpTransport, it might use a PSR-3 logger if integrated.
*
* @param string $message The message to log.
*/
public function log(string $message): void;

/**
* Checks if the transport connection is considered closed.
*
Expand Down