n1ywb / web-socket

A Polymer 2.0 element to ease the usage of WebSockets.

Home Page:https://hunsalz.github.io/web-socket/components/web-socket/demo/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Build Status License Published on webcomponents.org

<web-socket>

A Polymer 2.0 element to ease the usage of WebSockets.

Watch a live demo ↗

Install dependencies and run the demo locally

  1. Install all dependencies via Bower in the repo directory:
    bower install
  1. Run the demo automatically in your browser via the Polymer development server part of Polymer CLI from the project directory:
    polymer serve --open

Usage

<web-socket auto
            url="{{url}}"
            protocols="{{protocols}}"
            state="{{state}}"
            last-request="{{request}}"
            last-response="{{response}}"
            last-error="{{error}}"
            verbose>
</web-socket>

The above example illustrates the usage of <web-socket> in a Polymer app.

Attributes explained:

  • auto = Enables auto connection with page load
  • url = The URL to which to connect
  • protocols = An optional property to provide a single protocol string or an array of protocol strings.
  • state = The current state of the WebSocket connection. Notifies about state changes: WebSocket.readyState
  • 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.
  • verbose = Enables verbose mode

Run your own prototype WebSocket-Server without great effort

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.

About

A Polymer 2.0 element to ease the usage of WebSockets.

https://hunsalz.github.io/web-socket/components/web-socket/demo/

License:MIT License


Languages

Language:HTML 100.0%