Skip to content

mesopotamia/ws-element

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ws-element

Wrapper for browser-native WebSocket client. It's built using the Polymer project.

Usage

  1. Import Web Components' polyfill:

    <script src="bower_components/webcomponentsjs/webcomponents-lite.min.js"></script>
  2. Import Custom Element:

    <link rel="import" href="src/ws-element.html">
  3. Start using it!

    <ws-element url="ws://localhost:9999" protocol="echo-protocol"></ws-element>

Options

Attribute Options Default Description
url string undefined WebSocket server endpoint to connect to.
protocol string undefined A subset protocol to be used as part of the communication with the server.

Methods

Method Parameters Returns Description
send() message String Used to send messages to the server.
close() None Close socket.

Events

Event Description
onmessage Triggers when a message from the server is received.
onerror Triggers when there is an error triggered by WebSocket client
onopen Triggers when a socket is first open

About

Wrapper for browser-native WebSocket client. It's built using the Polymer project.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages