class Controller
Base class for controller objects designed to be proxied over Async::Bus.
Controllers provide an explicit API for remote operations, avoiding the confusion that comes from proxying generic objects like Array or Hash.
def append(*values)
self # Return self for chaining
end
def get(index)
end
def size
end
end
Controllers are automatically proxied when serialized if registered as a reference type in the Wrapper:
Wrapper.new(connection, reference_types: [Async::Bus::Controller])
This allows controller methods to return other controllers and have them automatically proxied.
Example: Array Controller
class ArrayController < Async::Bus::Controller
def initialize(array)
end
Example: Server Setup
server.accept do |connection|
array = []
controller = ArrayController.new(array)
connection.bind(:items, controller)
end
Example: Client Usage
client.connect do |connection|
items = connection[:items] # Returns proxy to controller
items.append(1, 2, 3) # Remote call
expect(items.size).to be == 3
end