A summary of data about the Ruby ecosystem.

https://github.com/imanel/websocket-ruby

Universal Ruby library to handle WebSocket protocol
https://github.com/imanel/websocket-ruby

Keywords from Contributors

rubygems activejob activerecord mvc rack rspec feature-flag static-code-analysis rubocop code-formatter

Last synced: about 5 hours ago
JSON representation

Repository metadata

Universal Ruby library to handle WebSocket protocol

README.md

WebSocket Ruby

Universal Ruby library to handle WebSocket protocol. It focuses on providing abstraction layer over WebSocket API instead of providing server or client functionality.

Gem Version
Gem Downloads
Code Climate

Autobahn tests: server, client

Currently WebSocket Ruby supports all existing drafts of WebSocket, which include:

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

@handshake = WebSocket::Handshake::Server.new

# Parse client request
@handshake << <<EOF
GET /demo HTTP/1.1\r
Upgrade: websocket\r
Connection: Upgrade\r
Host: example.com\r
Origin: http://example.com\r
Sec-WebSocket-Version: 13\r
Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==\r
\r
EOF

# All data received?
@handshake.finished?

# No parsing errors?
@handshake.valid?

# Create response
@handshake.to_s # HTTP/1.1 101 Switching Protocols
                # Upgrade: websocket
                # Connection: Upgrade
                # Sec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo=

Client handshake

@handshake = WebSocket::Handshake::Client.new(url: 'ws://example.com', headers: { 'Cookie' => '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 << <<EOF
HTTP/1.1 101 Switching Protocols\r
Upgrade: websocket\r
Connection: Upgrade\r
Sec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo=\r
\r
EOF

# All data received?
@handshake.finished?

# No parsing errors?
@handshake.valid?

Parsing and constructing frames

# Prepare frame for sending
frame = WebSocket::Frame::Outgoing::Server.new(version: @handshake.version, data: "Hello", type: :text)
frame.to_s # "\x81\x05\x48\x65\x6c\x6c\x6f"

# Parse incoming frames
frame = WebSocket::Frame::Incoming::Server.new(version: @handshake.version)
frame << "\x81\x05\x48\x65\x6c\x6c\x6f\x81\x06\x77\x6f\x72\x6c\x64\x21"
frame.next # "Hello"
frame.next # "world!""

Examples & Projects using WebSocket-Ruby

Native extension

WebSocket gem is written in pure Ruby, without any dependencies or native extensions and still is one of the fastest implementations of WebSocket API. However, if you want to increase it's speed even further, I created additional gem with dedicated native extensions for both C and Java. Those extensions provide 20-30% increase in speed(more accurate comparison can be found in autobahn test results)

In order to use native extension just install websocket-native gem or add it to Gemfile - WebSocket will automatically detect and load it.

Support

If you like my work then consider supporting me:

Donate with Bitcoin

Donate with Ethereum

License

(The MIT License)

Copyright © 2012 Bernard Potocki

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ‘Software’), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


Owner metadata


GitHub Events

Total
Last Year

Committers metadata

Last synced: 1 day ago

Total Commits: 368
Total Committers: 17
Avg Commits per committer: 21.647
Development Distribution Score (DDS): 0.092

Commits in past year: 0
Committers in past year: 0
Avg Commits per committer in past year: 0.0
Development Distribution Score (DDS) in past year: 0.0

Name Email Commits
Bernard Potocki b****i@i****g 334
Piotr Zientara 3****a@g****m 6
Nick Gauthier n****r@g****m 5
Dávid Halász d****z@r****m 3
Mark Bryant M****t@s****m 3
Olle Jonsson o****n@g****m 3
Pat Allan p****t@f****m 3
Yusuke Endoh m****e@r****g 2
Akira Matsuda r****e@d****p 1
Alex Rodionov p****e@g****m 1
Antonio Terceiro t****o@s****g 1
Juanito Fatas me@j****m 1
Masamitsu MURASE m****e@g****m 1
OKURA Masafumi m****8@g****m 1
Vít Ondruch v****h@r****m 1
adamjonas j****s@f****m 1
ecin e****n@c****m 1

Committer domains:


Issue and Pull Request metadata

Last synced: about 1 month ago

Total issues: 22
Total pull requests: 35
Average time to close issues: 3 months
Average time to close pull requests: 7 days
Total issue authors: 19
Total pull request authors: 22
Average comments per issue: 2.45
Average comments per pull request: 2.66
Merged pull request: 32
Bot issues: 0
Bot pull requests: 0

Past year issues: 0
Past year pull requests: 2
Past year average time to close issues: N/A
Past year average time to close pull requests: 6 days
Past year issue authors: 0
Past year pull request authors: 2
Past year average comments per issue: 0
Past year average comments per pull request: 1.5
Past year merged pull request: 1
Past year bot issues: 0
Past year bot pull requests: 0

More stats: https://issues.ecosyste.ms/repositories/lookup?url=https://github.com/imanel/websocket-ruby

Top Issue Authors

  • donpdonp (2)
  • imanel (2)
  • zh99998 (2)
  • skateman (1)
  • johnny (1)
  • nateless (1)
  • lukeredpath (1)
  • tarcieri (1)
  • gmallard (1)
  • ljckennedy (1)
  • andresespinosapc (1)
  • BanzaiMan (1)
  • Paxa (1)
  • julianschuh (1)
  • yfeldblum (1)

Top Pull Request Authors

  • imanel (11)
  • olleolleolle (3)
  • skateman (2)
  • amatsuda (2)
  • mark-young-atg (2)
  • mame (2)
  • voxik (1)
  • pat (1)
  • ecin (1)
  • mwylde (1)
  • Sumo-MBryant (1)
  • authorNari (1)
  • JuanitoFatas (1)
  • ianwdunlop (1)
  • goldibex (1)

Top Issue Labels

Top Pull Request Labels


Package metadata

gem.coop: websocket

Universal Ruby library to handle WebSocket protocol

  • Homepage: http://github.com/imanel/websocket-ruby
  • Documentation: http://www.rubydoc.info/gems/websocket/
  • Licenses: MIT
  • Latest release: 1.2.11 (published over 1 year ago)
  • Last Synced: 2025-12-11T01:01:35.724Z (1 day ago)
  • Versions: 24
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 172,223,349 Total
  • Docker Downloads: 803,678,778
  • Rankings:
    • Dependent repos count: 0.0%
    • Dependent packages count: 0.0%
    • Average: 0.066%
    • Docker downloads count: 0.117%
    • Downloads: 0.148%
  • Maintainers (1)
rubygems.org: websocket

Universal Ruby library to handle WebSocket protocol

  • Homepage: http://github.com/imanel/websocket-ruby
  • Documentation: http://www.rubydoc.info/gems/websocket/
  • Licenses: MIT
  • Latest release: 1.2.11 (published over 1 year ago)
  • Last Synced: 2025-12-11T12:33:33.866Z (about 13 hours ago)
  • Versions: 24
  • Dependent Packages: 75
  • Dependent Repositories: 77,101
  • Downloads: 172,289,679 Total
  • Docker Downloads: 803,678,778
  • Rankings:
    • Dependent repos count: 0.134%
    • Downloads: 0.215%
    • Dependent packages count: 0.392%
    • Docker downloads count: 0.497%
    • Average: 1.34%
    • Stargazers count: 2.707%
    • Forks count: 4.097%
  • Maintainers (1)
proxy.golang.org: github.com/imanel/websocket-ruby

  • Homepage:
  • Documentation: https://pkg.go.dev/github.com/imanel/websocket-ruby#section-documentation
  • Licenses:
  • Latest release: v1.2.11 (published over 1 year ago)
  • Last Synced: 2025-12-10T17:25:39.938Z (1 day ago)
  • Versions: 25
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Rankings:
    • Stargazers count: 2.773%
    • Forks count: 3.66%
    • Average: 6.703%
    • Dependent packages count: 9.576%
    • Dependent repos count: 10.802%

Dependencies

Gemfile rubygems
  • rake >= 0 development
  • rspec ~> 3.7 development
  • rubocop = 0.52.1 development
  • rubocop-rspec = 1.21.0 development
  • webrick >= 0 development
.github/workflows/publish.yml actions
  • actions/checkout v2 composite
  • cadwallion/publish-rubygems-action master composite
.github/workflows/test.yml actions
  • actions/checkout v2 composite
  • ruby/setup-ruby v1 composite
websocket.gemspec rubygems

Score: 30.345604893441568