Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/minoritea/sinatra-hijacker
https://github.com/minoritea/sinatra-hijacker
Last synced: 1 day ago
JSON representation
- Host: GitHub
- URL: https://github.com/minoritea/sinatra-hijacker
- Owner: minoritea
- License: mit
- Created: 2013-08-23T00:00:58.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2014-12-19T16:59:08.000Z (about 10 years ago)
- Last Synced: 2024-11-12T10:18:34.241Z (2 months ago)
- Language: Ruby
- Size: 170 KB
- Stars: 4
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Sinatra::Hijacker
A sinatra plugin to handle websockets by Rack hijacking API.
## Installation
Add this line to your application's Gemfile:
gem 'sinatra-hijacker'
And then execute:
$ bundle
Or install it yourself as:
$ gem install sinatra-hijacker
## Usage
Register Sinatra::Hijacker and define route by "websocket" method:
```ruby
require 'sinatra'
require 'sinatra/hijacker'class YourApp < Sinatra::Base
register Sinatra::Hijacker
websocket '/ws' do
ws.onopen{ws.send_data "hello"}
ws.onmessage{|msg| puts msg}
end
end
```or in classic style:
```ruby
require 'sinatra'
require 'sinatra/hijacker'register Sinatra::Hijacker
websocket '/ws' do
ws.onopen{ws.send_data "hello"}
ws.onmessage{|msg| puts msg}
end
```Note: application server must support Rack hijacking API, like Puma.
## Contributing
1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request