public protocol StreamRequest : NetworkRequest
A request for a steram is similar to a
Request, only that it does not send an HTTP request,
but asks for a web socket. Instead of a
Response that yields at most one value, it therefore
Stream which allows for receiving arbitrarily many values as well as sending values.
Apart from that, working with a stream request is very similar to working with an HTTP request.
It is also scheduled against an API represented by an
HttpService. However, the service’s
retriers as well as its headers are ignored. Still, the
Service.process(_:) method is called.
Defines the type of the values sent by the client to the peer. By default, this is set to
Void, indicating unidirectional communication from the peer to the client.
associatedtype Message = Void
Defines the type of the values sent from the peer to the client.
Encodes a message sent from the client to the peer into an appropriate format for WebSocket communication. There exist default implementations for the case where
Messageis of type
String. In the first case, an error is thrown (as
Voidindicates unidirectional communication from the peer to the client). In the latter two cases, the returned value can be synthesized trivially.
The message to be sent from the client to the peer.
Decodes a message sent by the peer into the stream’s result type. There exist default implementations for result types
String. In the former case, a
Voidvalue is returned no matter the message, in the latter two cases, the return value can be synthesized easily.
The message sent by the peer.
Schedules the stream request against the API specified by the given HTTP service. The returned value is the stream over which messages can be sent (bidirectionally). Note that this method is very similar to
The service representing the API against which to schedule this request.