A protocol defining a client for Speechly SLU API.
public protocol SluClientProtocol
It exposes functionality for starting and stopping SLU recognition streams and a delegate for receiving the responses.
A delegate which is called when the client receives messages from the API or catches errors.
var delegate: SluClientDelegate?
Connects to the SLU API.
func connect(token: ApiAccessToken, config: SluConfig) -> EventLoopFuture<Void>
- token: An auth token received from Speechly Identity API.
- config: The configuration of the SLU stream.
A future which will be fullfilled when the stream has been connected.
Disconnects the current connection to the SLU API.
func disconnect() -> EventLoopFuture<Void>
If there is an active Context
, it is cancelled.
A future which is fulfilled when the stream has been disconnected.
Starts a new SLU recognition stream.
func startContext(appId: String?) -> EventLoopFuture<Void>
- appId: The target appId for the audio, if not set in the token.
A future which will be fullfilled when the stream has been started.
Stops the current SLU recognition stream
func stopContext() -> EventLoopFuture<Void>
A future which will be fullfilled when the stream has been closed from the client side.
Suspends the client by terminating any in-flight streams and disconnecting the channels.
func suspend() -> EventLoopFuture<Void>
A future which will be fullfilled when the streams and channels are cleaned up.
Resumes the client by restoring the channels and cleaning up any stale streams.
func resume() -> EventLoopFuture<Void>
A future which will be fullfilled when the channels are restored.
Writes audio data on the current stream.
func write(data: Data) -> EventLoopFuture<Void>
- data: The audio data to write to the stream
A future which will be fullfilled when the data has been sent.