wamp.io icon indicating copy to clipboard operation
wamp.io copied to clipboard

It seems a bit different from WAMP specification

Open Kenzku opened this issue 13 years ago • 3 comments

I am not sure if I understand correctly, it seems your server only accept PUBLISH and the format is a bit different from WAMP specification? http://wamp.ws/spec#publish_message

It says: publish (a) message with 'string' as payload [7, "http://example.com/simple", "Hello, world!"]

While your code: try { var parsed = qs.parse(buffer); console.log(parsed); topicUri = parsed.topicuri; event = JSON.parse(parsed.body); }

It seems you need "topicuri" and "body", but the server does not accept: {"topicuri":"http://example.com/simple","body":"something"} or topicuri=http://example.com/simple&body=something (based on https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/JSON/parse, it should accept body=something)

While it will accept: topicuri=http://example.com/simple&body={"event":"helleo"} (and this way is different from the specification, maybe?)

Screen Shot 2013-03-01 at 16 27 03

Kenzku avatar Mar 01 '13 14:03 Kenzku

You are right, the little server in the example code only supports PUBLISH – while SUBSCRIBE can be done in the client (which is not implemented here, you can use the original Autobahn library). Note this is only an example.

The examples/pubsub/server.js runs an HTTP server on port 9000 that accepts WebSocket connections (via websocket.io) that talk the WAMP protocol. For convenience, you can also publish events using HTTP POST. Here the event to be published must be URI encoded in the POST body, like "topicUri=...&body=Hello+World". With this you can implement a veeery "basic" pub sub-hub.

On 01.03.2013, at 15:27, Watke [email protected] wrote:

I am not sure if I understand correctly, it seems your server only accept PUBLISH and the format is a bit different from WAMP specification? http://wamp.ws/spec#publish_message

It says: publish (a) message with 'string' as payload [7, "http://example.com/simple", "Hello, world!"]

While your code: try { var parsed = qs.parse(buffer); console.log(parsed); topicUri = parsed.topicuri; event = JSON.parse(parsed.body); }

It seems you need "topicuri" and "body", but the server does not accept: {"topicuri":"http://example.com/simple","body":"something"}

— Reply to this email directly or view it on GitHub.

nicokaiser avatar Mar 01 '13 19:03 nicokaiser

hmm, it seems I did not understand something - the protocol format [7, "http://example.com/simple", "Hello, world!"] looks different from your implementation format "topicUri=...&body=Hello+World"?

Kenzku avatar Mar 04 '13 08:03 Kenzku

My implementation uses the same format [7, "http://example.com/simple", "Hello, world!"], but the protocol for pushing message to the server (not via WAMP but via HTTP POST) is different.

nicokaiser avatar Mar 04 '13 08:03 nicokaiser