Watch <web-socket>↗ live
A Polymer 3.0 element to ease the usage of WebSockets.
- Build <web-socket> in the repo directory:
$ polymer build
- Run the demo automatically in your browser:
$ polymer serve --open
Example of <web-socket>
:
<web-socket url="{{url}}"
protocols="{{protocols}}"
state="{{state}}"
last-request="{{request}}"
last-response="{{response}}"
last-error="{{error}}"
retry
connect-attempts="{{connectAttempts}}">
</web-socket>
Attributes explained:
- url = Describes the WebSocket server URL
- protocols = Describes a single protocol string or a collection of protocol strings
- state = Provides the current state of the WebSocket connection. Notifies about WebSocket.readyState changes.
- last-request = The most recent request made by this web-socket element.
- last-response = The most recent response received by this web-socket element.
- last-error = The most recent error received by this web-socket element. If any error occurred.
- retry = Redelivers messages after a connection break-down
- connectAttempts = Counts and notify re-connection attempts
Almost all demo references uses wss://echo.websocket.org/ as WebSocket-Server. This demo makes no difference. If you search for a local alternative, you can get up and running in minutes with httpwebsockethandler by SevenW.