| Action Engine
             | 
An abstract base class for an ActionEngine stream.
This class provides an interface for sending and receiving messages over a stream. It is intended to be used as a base class for specific stream implementations, such as WebSocket or gRPC streams.
#include <actionengine/net/stream.h>
| Public Member Functions | |
| virtual auto | Send (WireMessage message) -> absl::Status=0 | 
| virtual auto | Receive (absl::Duration timeout) -> absl::StatusOr< std::optional< WireMessage > >=0 | 
| virtual auto | Accept () -> absl::Status=0 | 
| virtual auto | Start () -> absl::Status=0 | 
| virtual void | HalfClose ()=0 | 
| virtual void | Abort ()=0 | 
| virtual auto | GetStatus () const -> absl::Status=0 | 
| virtual auto | GetId () const -> std::string=0 | 
| virtual auto | GetImpl () const -> const void * | 
| template<typename T> | |
| auto | GetImpl () const -> T * | 
| 
 | pure virtual | 
Aborts the stream.
This is used to terminate the stream immediately with an "error" state. For example, the result of Receive() following an Abort() call by either side should be an error status, indicating that the stream is no longer usable, and not an empty optional.
Implemented in act::net::WebRtcWireStream, act::net::WebsocketWireStream, and act::pybindings::PyWireStream.
| 
 | pure virtual | 
Accepts the stream on the server side.
Clients should not call this method. It is intended to be called by the server to accept a stream that has been initiated by a client. Implementations that differentiate between client and server streams are allowed to return an error if this method is called on a client, or even to perform a hard termination of the process, as such a call is considered a misuse of the API.
Some implementations may not require this method, in which case they can return an OK status without doing anything.
Implemented in act::net::WebRtcWireStream, act::net::WebsocketWireStream, and act::pybindings::PyWireStream.
| 
 | nodiscardpure virtual | 
Returns the unique (in this process) identifier of the stream.
Implemented in act::net::WebRtcWireStream, act::net::WebsocketWireStream, and act::pybindings::PyWireStream.
| 
 | inlinenodiscardvirtual | 
Returns the underlying implementation of the stream.
This function is intended to be overridden by derived classes to provide access to the specific implementation of the stream, in case such access is required. The default implementation returns a null pointer.
Reimplemented in act::net::WebRtcWireStream, and act::net::WebsocketWireStream.
| 
 | inlinenodiscard | 
Returns the underlying implementation of the stream.
This function is a template that allows the user to specify the type of the underlying implementation. It uses static_cast to convert the void* pointer returned by GetImpl() to the specified type.
| T | The type of the underlying implementation. | 
T. | 
 | pure virtual | 
Returns the status of the stream.
This method is used to check the current status of the stream, which is OK unless the stream has been aborted.
absl::Status indicating the current status of the stream. If the stream is in a valid state, it returns absl::OkStatus(). If the stream is in an error state (e.g., due to an abort), it returns an appropriate error status. Implemented in act::net::WebRtcWireStream, act::net::WebsocketWireStream, and act::pybindings::PyWireStream.
| 
 | pure virtual | 
Communicates to the other end that no more messages will be sent over this stream.
Implemented in act::net::WebRtcWireStream, act::net::WebsocketWireStream, and act::pybindings::PyWireStream.
| 
 | pure virtual | 
Receives an ActionEngine wire message from the stream.
Blocks to wait for a message to be received, up to the specified timeout.
| timeout | The maximum duration to wait for a message to be received. If the timeout is reached, the function will return an absl::DeadlineExceededError. | 
Receive() is called in a loop, and the loop should be able to terminate gracefully when the stream is aborted. Implemented in act::net::WebRtcWireStream, act::net::WebsocketWireStream, and act::pybindings::PyWireStream.
| 
 | pure virtual | 
Sends a WireMessage over the stream.
May or may not block, depending on the implementation. For example, WebsocketWireStream will block until the message is sent, while WebRtcWireStream will return immediately, allowing the message to be sent asynchronously.
With that in mind, the caller should not assume that the message has been sent immediately after this function returns, or even that it has been sent successfully. Failure modes of this method are more about the invariants of the stream itself: for example, if the stream is closed, or half-closed (no more messages can be sent), this method will return an error.
| message | The WireMessage to send, containing action calls (in the form of multiple ActionMessage) and/or node fragments. | 
Implemented in act::net::WebRtcWireStream, act::net::WebsocketWireStream, and act::pybindings::PyWireStream.
| 
 | pure virtual | 
Starts the stream on the client side.
Clients should call this method to initiate the stream after it has been created. This method is intended to be called by the client to start the stream, which may involve some underlying negotiation or setup. Implementations that differentiate between client and server streams are allowed to return an error if this method is called on a server, or even to perform a hard termination of the process, as such a call is considered a misuse of the API.
Some implementations may not require this method, in which case they can return an OK status without doing anything.
Implemented in act::net::WebRtcWireStream, act::net::WebsocketWireStream, and act::pybindings::PyWireStream.