{"id":13879873,"url":"https://github.com/palkan/litecable","last_synced_at":"2025-05-16T01:05:41.463Z","repository":{"id":48898211,"uuid":"80248313","full_name":"palkan/litecable","owner":"palkan","description":"Lightweight Action Cable implementation (Rails-free)","archived":false,"fork":false,"pushed_at":"2024-04-26T19:15:45.000Z","size":3620,"stargazers_count":302,"open_issues_count":0,"forks_count":31,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-05-12T22:45:40.876Z","etag":null,"topics":["actioncable","sinatra","websockets"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/palkan.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-01-27T21:38:43.000Z","updated_at":"2025-04-29T09:06:01.000Z","dependencies_parsed_at":"2024-04-26T20:37:59.088Z","dependency_job_id":null,"html_url":"https://github.com/palkan/litecable","commit_stats":{"total_commits":60,"total_committers":8,"mean_commits":7.5,"dds":0.35,"last_synced_commit":"43244077fa964e39cef1b6493c5c71a6a4b9c3b0"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/palkan%2Flitecable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/palkan%2Flitecable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/palkan%2Flitecable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/palkan%2Flitecable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/palkan","download_url":"https://codeload.github.com/palkan/litecable/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254448579,"owners_count":22072764,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["actioncable","sinatra","websockets"],"created_at":"2024-08-06T08:02:37.021Z","updated_at":"2025-05-16T01:05:36.435Z","avatar_url":"https://github.com/palkan.png","language":"Ruby","funding_links":[],"categories":["Ruby"],"sub_categories":[],"readme":"[![Gem Version](https://badge.fury.io/rb/litecable.svg)](https://rubygems.org/gems/litecable)\n[![Build](https://github.com/palkan/litecable/workflows/Build/badge.svg)](https://github.com/palkan/litecable/actions)\n\n# Lite Cable\n\nLightweight ActionCable implementation.\n\nContains application logic (channels, streams, broadcasting) and also (optional) Rack hijack based server (suitable only for development and test due to its simplicity).\n\nCompatible with [AnyCable](http://anycable.io) (for production usage).\n\n\u003ca href=\"https://evilmartians.com/\"\u003e\n\u003cimg src=\"https://evilmartians.com/badges/sponsored-by-evil-martians.svg\" alt=\"Sponsored by Evil Martians\" width=\"236\" height=\"54\"\u003e\u003c/a\u003e\n\n## Examples\n\n- [Sinatra LiteCable Chat](https://github.com/palkan/litecable/tree/master/examples/sinatra)\n\n- [Connecting LiteCable to Hanami](http://gabrielmalakias.com.br/ruby/hanami/iot/2017/05/26/websockets-connecting-litecable-to-hanami.html) by [@GabrielMalakias](https://github.com/GabrielMalakias)\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem \"litecable\"\n```\n\nAnd run `bundle install`.\n\n## Usage\n\nPlease, checkout [Action Cable guides](http://guides.rubyonrails.org/action_cable_overview.html) for general information. Lite Cable aims to be compatible with Action Cable as much as possible without the loss of simplicity and _lightness_.\n\nYou can use Action Cable javascript client without any change (precompiled version can be found [here](https://github.com/palkan/litecable/tree/master/examples/sinatra/assets/cable.js)).\n\nHere are the differences:\n\n- Use `LiteCable::Connection::Base` as a base class for your connection (instead of `ActionCable::Connection::Base`)\n\n- Use `LiteCable::Channel::Base` as a base class for your channels (instead of `ActionCable::Channel::Base`)\n\n- Use `LiteCable.broadcast` to broadcast messages (instead of `ActionCable.server.broadcast`)\n\n- Explicitly specify channels names:\n\n```ruby\nclass MyChannel \u003c LiteCable::Channel::Base\n  # Use this id in your client to create subscriptions\n  identifier :chat\nend\n```\n\n```js\nApp.cable.subscriptions.create('chat', ...)\n```\n\n### Using a custom channel registry\n\nAlternatively to eager loading all channel classes and providing identifiers, you can build a custom _channel registry_ object, which can perform channel class lookups:\n\n```ruby\n# DummyRegistry which always returns a predefined channel class\nclass DummyRegistry\n  def lookup(channel_id)\n    DummyChannel\n  end\nend\n\nLiteCable.channel_registry = DummyRegistry.new\n```\n\n### Using built-in server (middleware)\n\nLite Cable comes with a simple Rack middleware for development/testing usage.\nTo use Lite Cable server:\n\n- Add `gem \"websocket\"` to your Gemfile\n\n- Add `require \"lite_cable/server\"`\n\n- Add `LiteCable::Server::Middleware` to your Rack stack, for example:\n\n```ruby\nRack::Builder.new do\n  map \"/cable\" do\n    # You have to specify your app's connection class\n    use LiteCable::Server::Middleware, connection_class: App::Connection\n    run proc { |_| [200, {\"Content-Type\" =\u003e \"text/plain\"}, [\"OK\"]] }\n  end\nend\n```\n\n### Using with AnyCable\n\nLite Cable is AnyCable-compatible out-of-the-box.\n\nIf AnyCable gem is loaded, you don't need to configure Lite Cable at all.\n\nOtherwise, you must configure broadcast adapter manually:\n\n```ruby\nLiteCable.broadcast_adapter = :any_cable\n```\n\nYou can also do this via configuration, e.g., env var (`LITECABLE_BROADCAST_ADAPTER=any_cable`) or `broadcast_adapter: any_cable` in a YAML config.\n\n**At the AnyCable side**, you must configure a connection factory:\n\n```ruby\nAnyCable.connection_factory = MyApp::Connection\n```\n\nThen run AnyCable along with the app:\n\n```sh\nbundle exec anycable\n\n# add -r option to load the app if it's not ./config/anycable.rb or ./config/environment.rb\nbundle exec anycable -r ./my_app.rb\n```\n\nSee [Sinatra example](https://github.com/palkan/litecable/tree/master/examples/sinatra) for more.\n\n### Configuration\n\nLite Cable uses [anyway_config](https://github.com/palkan/anyway_config) for configuration.\n\nSee [config](https://github.com/palkan/litecable/blob/master/lib/lite_cable/config.rb) for available options.\n\n### Unsupported features\n\n- Channel callbacks (`after_subscribe`, etc)\n\n- Stream callbacks (`stream_from \"xyz\" { |msg| ... }`)\n\n- Periodical timers\n\n- Remote connections.\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at [https://github.com/palkan/litecable](https://github.com/palkan/litecable).\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](./LICENSE.txt).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpalkan%2Flitecable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpalkan%2Flitecable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpalkan%2Flitecable/lists"}