# QuicProChat Ruby SDK Ruby FFI gem wrapping `libquicprochat_ffi` for the quicprochat E2E encrypted messenger. ## Prerequisites - Ruby 3.1+ - `libquicprochat_ffi` built for the target platform ## Installation ```sh gem install quicprochat ``` Or add to your Gemfile: ```ruby gem "quicprochat" ``` ## Building the Native Library ```sh cargo build --release -p quicprochat-ffi ``` Set `QPC_LIB_PATH` if the library is not in the default search path. ## Usage ```ruby require "quicprochat" # Block form (auto-disconnect) QuicProChat::Client.open("127.0.0.1:5001", ca_cert: "ca.pem") do |client| client.login("alice", "secret") client.send("bob", "hello from Ruby!") messages = client.receive(timeout_ms: 5000) messages.each { |msg| puts msg } end # Manual lifecycle client = QuicProChat::Client.new("127.0.0.1:5001", ca_cert: "ca.pem") client.login("alice", "secret") client.send("bob", "hello") client.disconnect ``` ## API | Method | Description | |---|---| | `Client.new(server, ca_cert:, server_name:)` | Connect to server | | `Client.open(server, **opts) { \|c\| ... }` | Connect with auto-disconnect | | `client.login(username, password)` | OPAQUE authentication | | `client.send(recipient, message)` | Send message by username | | `client.receive(timeout_ms: 5000)` | Receive pending messages | | `client.disconnect` | Disconnect | | `client.connected?` | Connection status | ## Error Handling ```ruby begin client.login("alice", "wrong") rescue QuicProChat::AuthError => e puts "Auth failed: #{e.message}" rescue QuicProChat::TimeoutError => e puts "Timeout: #{e.message}" rescue QuicProChat::Error => e puts "Error: #{e.message}" end ``` ## Structure - `lib/quicprochat/client.rb` -- High-level client - `lib/quicprochat/ffi_bindings.rb` -- FFI function declarations - `lib/quicprochat/errors.rb` -- Exception classes - `examples/demo.rb` -- Usage example