I register an RCP procedure using the Thruway client and call it using the Autohahn client.
The issue I faced is that when the callee returns an empty array from the procedure return array();
the caller receives the null
value.
When the callee returns a single-element array return array(['foo' => 'bar', 'baz' => 'quux']);
the caller receives that object which is not wrapped in an array.
And only returning multiple objects in an array works as expected: the caller receives an array of objects.
This is absolutely inconvenient and unintuitive: I have to check whether the response is defined, whether it's an array or not... I wish the caller to receive what I actually send from the callee: an empty array, an array of one element and an array of multiple elements. I send an array - I want the client to get an array.
The question is: how to fix this behavior? I'm not even sure which of the two clients is misconfigured. Or maybe this is configurable on router (I use Crossbar as a router). Or maybe this is an expected implementation of the protocol (which would be just awful).