A Polymer websocket element with support for subprotocols
BSD-2-CLAUSE License
A Polymer wrapper for the Websocket API with support for subprotocols.
<websocket-component url="{{wsURL}}"
protocols="{{wsProtocols}}"
status="{{wsStatus}}"
auto>
</websocket-component>
As the example above shows, it is possible to data-bind to some of the websocket values.
The following events are thrown:
event.detail.data
contains more info about the error.event.detail.data
contains the message.event.detail.code
contains the closing code. event.detail.reason
contains the reason code.<shared-websocket-component socket-id="1" url="ws://echo.websocket.org"></shared-websocket-component>
It is now possible to share a single websocket instance between multiple websocket-component instances. Set the socket-id property to indicate which websocket instance should be used. Thanks @bastiion!
You can install this element with bower:
bower i websocket-component -S
More api documentation, a demo and the tests can be found [here] (http://wburgers.github.io/websocket-component).
(To see the tests, add /test/
to the url after it resolves).