crossbario / autobahn-js

WAMP in JavaScript for Browsers and NodeJS
http://crossbar.io/autobahn
MIT License
1.44k stars 230 forks source link

add client-side prefixes #66

Closed goeddea closed 10 years ago

goeddea commented 10 years ago

While with WAMP v2 there are no prefixes on the wire anymore, something like session.prefix("api", "com.myapp.api"); session.call("api:get_events").then(...) is nicer to write and read than var apiBaseUri = "com.myapp.api."; session.call(apiBaseUri + "get_events").then(...)

oberstet commented 10 years ago

Above is easy to do and useful. So we probably should add it.

A question is if we want to do it based on strings

session.prefix("api", "com.myapp.api");
session.call("api:get_events").then(...);

or like this:

session.prefix()
session.call.api.get_events().then(...);

Another option would be with WAMP Reflection. The latter allows a client to query for available procedures and topics.

goeddea commented 10 years ago

The first variant keeps with the syntax for non-prefixed calls, while the second introduces a new syntax.

This by itself seems already unnecessary.

Additionally, in actual use, for publications and subscriptions, the first notation feels more natural when assembling a string for the action, e.g.

session.publish("api:sensor_activated." + sensorID)

vs.

session.publish.api["sensor_activated." + sensorID]