Is it possible to receive an Amazon SNS message on a JS script?

后端 未结 2 1083
傲寒
傲寒 2021-01-01 11:38

I know some options using ruby on rails and/or node.js and PubNuB, a service that has many APIs so you can send/receive notifications between (almost) any platform.

2条回答
  •  一向
    一向 (楼主)
    2021-01-01 12:32

    Yes, but not directly and you'll have to poll for messages on a timer...

    In the Product Details page under the heading "Flexible", you'll see that none of the currently supported formats/transports can be hosted in the browser.

    However... Amazon SQS is one of the supported transports, and it in turn can be accessed from JavaScript - see an example app here: http://aws.amazon.com/code/Amazon-SQS/1254. (The example shows JavaScript accessing SQS).

    You'd have to manually poll though, as there is no "push" to the browser with SQS.

    (Alternatively, you could do it all server-side, and then you could use potentially use websockets to push the messages to the browser.)

提交回复
热议问题