start method
Future<void>
start(
{ - bool public = false,
})
inherited
Implementation
Future<void> start({bool public = false}) async {
if (_started) {
throw RoomServerException("toolkit '$name' is already started");
}
room.protocol.addHandler("agent.tool_call.$name", _toolCall);
room.protocol.addHandler("agent.tool_call_request_chunk.$name", _toolCallRequestChunk);
try {
await _register(public: public);
_started = true;
unawaited(
room.protocol.done.then((error) async {
final wrapped = error == null
? RoomServerException("room client was closed before streamed tool call request completed")
: RoomServerException("room client closed with error: $error");
await _failActiveRequestStreams(error: wrapped);
}),
);
} catch (_) {
room.protocol.removeHandler("agent.tool_call.$name", _toolCall);
room.protocol.removeHandler("agent.tool_call_request_chunk.$name", _toolCallRequestChunk);
rethrow;
}
}