Skip to content
Eric Chapman edited this page Dec 14, 2018 · 3 revisions

The Ruby Wamp::Worker provides a way to integrate WAMP into larger applications including Ruby on Rails.

This GEM uses the following other libraries

  • wamp_client to connect to a WAMP router
  • redis to handle messages between the different applications
  • sidekiq optionally to push registrations and subscriptions to the background

For more information, please see the following chapters.

  • Runner - encapsulates running the worker(s)
  • Configuration - supports configuring the worker(s)
  • Handlers - provides implementing registrations and subscriptions
  • Proxy - abstracts the Redis communication

Quick Start

require "wamp/worker"

class MyHandler
  include Wamp::Worker::Handler

  register "com.example.add", :add
  register "com.example.subtract", :subtract
  subscribe "com.example.listener", :listener

  def add
    args[0] + args[1]
  end
  
  def subtract
    args[0] - args[1]
  end
  
  def listener
    # Do something
  end
end

Wamp::Worker.log_level = :debug

Wamp::Worker.configure do
  connection uri: 'ws://127.0.0.1:8080/ws', realm: 'realm1'
end

Wamp::Worker.run
Clone this wiki locally