0

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).

Kolyunya
  • 5,973
  • 7
  • 46
  • 81

1 Answers1

1

Just tested this with two Autobahn clients (Autobahn|JS, but behavior in this respect is identical across Autobahns) and Crossbar.io. This results in an empty array, an array with one element and an array with multiple elements being received.

This is spec-conformant behavior: The caller receives what is sent from the callee. The only modification the router performs on the payload is to change the serialization if needed.

gzost
  • 2,375
  • 1
  • 18
  • 25