iron-socket-io-client
Polymer element to connect to socket.IO WebSocket
[ This description is mirrored from README.md at github.com/Collaborne/iron-socket-io-client on 2019-05-10 ]
iron-socket-io-client
Polymer element to connect to socket-IO
This element uses Polymer 2 native classes (ES6 syntax).
Install
bower install --save Collaborne/iron-socket-io-client
Usage
The component provides an imperative interface to connect to a Socket.IO server. The messages emitted by the server must use the event message
, and must be objects with minimally a type
property. Handlers can be defined based on (a prefix of) the type
property of the messages.
- Embed the component
- Call
invoke(uri, [token])
to connect to the/socket.io/
location at the given URI. The optionaltoken
argument will be used as 'Bearer' token in theauthorization
header of the initial request. - Call
registerHandler(typePrefix, handler)
to receive messages with theirtype
property starting the with the prefixtypePrefix
. The handler is invoked with the complete message as argument, and any return value of the handler is ignored. All handlers matching a message are involved in the order of registration. - Call
send(message)
to sendmessage
events to the server, oremit(type, message)
to emit events with the given type. - Monitor event
iron-socket-io-client-error
for potential errors on the WebSocket connection
License
This software is licensed under the Apache 2 license, quoted below.
Copyright 2011-2017 Collaborne B.V. <http://github.com/Collaborne/>
Licensed under the Apache License, Version 2.0 (the "License"); you may not
use this file except in compliance with the License. You may obtain a copy of
the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
License for the specific language governing permissions and limitations under
the License.
Links
Compatibility
Was this helpful? Need more help?
Leave a comment or a question below. You can also join
the chat on Discord or
ask questions on StackOverflow.
Version
Dependencies
- polymer#Polymer/polymer#^2.0.0
- socket.io-client#^2.0.2
- Released
- 2018-10-04
- Maturity
- IMPORTED
- License
- Apache License 2.0
Compatibility
- Framework
- Polymer 2.0+
- Browser
- Browser Independent