# Lite Cable

> Lightweight Action Cable implementation to bring Rails real-time experience to any Ruby application.

- URL: https://evilmartians.com/opensource/litecable
- GitHub: https://github.com/palkan/litecable
- Authors: Vladimir Dementyev

---

Lite Cable allows you to build real-time Ruby applications using the same abstractions as Ruby on Rails provides and transparently integrates with AnyCable to handle WebSocket connections.

Lite Cable provides Connection and Channel abstractions to design real-time features in your application:

```ruby
class Connection < LiteCable::Connection::Base
  def connect
    # perform authentication here
  end
end

class ChatChannel < LiteCable::Channel::Base
  # Use this id in your client to create subscriptions
  identifier :chat
end
```

At the client-side, you can use any Action Cable library (including the official Rails one).

Lite Cable is designed to be used with [AnyCable][]. All you need to do is configure the connection factory for AnyCable:

```ruby
AnyCable.connection_factory = Connection
```

Alternatively, you can use a simple Rack-based WebSocket server implementation which comes with the library:

```ruby
require "lite_cable/server"

Rack::Builder.new do
  map "/cable" do
    # You have to specify your app's connection class
    use LiteCable::Server::Middleware, connection_class: Connection
    run proc { |_| [200, {"Content-Type" => "text/plain"}, ["OK"]] }
  end
end
```

[AnyCable]: https://evilmartians.com/products/anycable
