Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/imanel/websocket-ruby
Universal Ruby library to handle WebSocket protocol
https://github.com/imanel/websocket-ruby
Last synced: 2 months ago
JSON representation
Universal Ruby library to handle WebSocket protocol
- Host: GitHub
- URL: https://github.com/imanel/websocket-ruby
- Owner: imanel
- Created: 2010-12-05T00:50:28.000Z (about 14 years ago)
- Default Branch: master
- Last Pushed: 2023-09-19T09:30:57.000Z (over 1 year ago)
- Last Synced: 2024-04-14T23:59:34.972Z (9 months ago)
- Language: Ruby
- Homepage:
- Size: 2.74 MB
- Stars: 440
- Watchers: 15
- Forks: 42
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
- awesome-ruby-toolbox - websocket - Universal Ruby library to handle WebSocket protocol (Web Apps, Services & Interaction / HTTP Pub/Sub)
README
# WebSocket Ruby
Universal Ruby library to handle WebSocket protocol. It focuses on providing abstraction layer over [WebSocket API](http://dev.w3.org/html5/websockets/) instead of providing server or client functionality.
[![Gem Version](https://badge.fury.io/rb/websocket.svg)](http://badge.fury.io/rb/websocket)
[![Gem Downloads](https://img.shields.io/gem/dt/websocket.svg?maxAge=2592000)](https://rubygems.org/gems/websocket)
[![Code Climate](https://codeclimate.com/github/imanel/websocket-ruby.svg)](https://codeclimate.com/github/imanel/websocket-ruby)**Autobahn tests:** [server](http://imanel.github.com/websocket-ruby/autobahn/server/), [client](http://imanel.github.com/websocket-ruby/autobahn/client/)
Currently WebSocket Ruby supports all existing drafts of WebSocket, which include:
- [hixie-75](http://tools.ietf.org/html/draft-hixie-thewebsocketprotocol-75)
- [hixie-76](http://tools.ietf.org/html/draft-hixie-thewebsocketprotocol-76)
- [all hybi drafts (00-13)](http://tools.ietf.org/html/draft-ietf-hybi-thewebsocketprotocol-17)
- [RFC 6455](http://datatracker.ietf.org/doc/rfc6455/)## Installation
WebSocket Ruby has no external dependencies, so it can be installed from source or directly from rubygems:
```
gem install "websocket"
```or via Gemfile:
```
gem "websocket"
```## Server handshake
``` ruby
@handshake = WebSocket::Handshake::Server.new# Parse client request
@handshake << < 'SESSIONID=1234' })# Create request
@handshake.to_s # GET /demo HTTP/1.1
# Upgrade: websocket
# Connection: Upgrade
# Host: example.com
# Cookie: SESSIONID=1234
# Origin: http://example.com
# Sec-WebSocket-Version: 13
# Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==# Parse server response
@handshake << <