@@ -35,13 +35,13 @@ class ConsumedThing implements scripting_api.ConsumedThing {
3535 /// Determines the id of this [ConsumedThing] .
3636 String get identifier => thingDescription.identifier;
3737
38- (ProtocolClient client, AugmentedForm form) _getClientFor (
38+ Future < (ProtocolClient client, AugmentedForm form)> _getClientFor (
3939 List <Form > forms,
4040 OperationType operationType,
4141 InteractionAffordance interactionAffordance, {
4242 required int ? formIndex,
4343 required Map <String , Object >? uriVariables,
44- }) {
44+ }) async {
4545 final augmentedForms = forms
4646 .map (
4747 (form) => AugmentedForm .new (
@@ -59,7 +59,7 @@ class ConsumedThing implements scripting_api.ConsumedThing {
5959 if (formIndex >= 0 && formIndex < forms.length) {
6060 foundForm = augmentedForms[formIndex];
6161 final scheme = foundForm.href.scheme;
62- client = servient.clientFor (scheme);
62+ client = await servient.createClient (scheme);
6363 } else {
6464 throw ArgumentError (
6565 'ConsumedThing "$title " missing formIndex for '
@@ -86,7 +86,7 @@ class ConsumedThing implements scripting_api.ConsumedThing {
8686 orElse: () => throw Exception ("No matching form found!" ),
8787 );
8888 final scheme = foundForm.href.scheme;
89- client = servient.clientFor (scheme);
89+ client = await servient.createClient (scheme);
9090 }
9191
9292 return (client, foundForm);
@@ -108,7 +108,7 @@ class ConsumedThing implements scripting_api.ConsumedThing {
108108 );
109109 }
110110
111- final (ProtocolClient client, AugmentedForm form) = _getClientFor (
111+ final (ProtocolClient client, AugmentedForm form) = await _getClientFor (
112112 property.forms,
113113 OperationType .readproperty,
114114 property,
@@ -137,7 +137,7 @@ class ConsumedThing implements scripting_api.ConsumedThing {
137137 );
138138 }
139139
140- final (client, form) = _getClientFor (
140+ final (client, form) = await _getClientFor (
141141 property.forms,
142142 OperationType .writeproperty,
143143 property,
@@ -173,7 +173,7 @@ class ConsumedThing implements scripting_api.ConsumedThing {
173173 );
174174 }
175175
176- final (client, form) = _getClientFor (
176+ final (client, form) = await _getClientFor (
177177 action.forms,
178178 OperationType .invokeaction,
179179 action,
@@ -269,7 +269,7 @@ class ConsumedThing implements scripting_api.ConsumedThing {
269269 subscriptions = _subscribedEvents;
270270 }
271271
272- final (client, form) = _getClientFor (
272+ final (client, form) = await _getClientFor (
273273 affordance.forms,
274274 operationType,
275275 affordance,
0 commit comments