Class: Arpie::ProxyServer

Inherits:
Server
  • Object
show all
Defined in:
lib/arpie/proxy.rb

Overview

A Endpoint which supports arbitary objects as handlers, instead of a proc.

Note that this will only export public instance method of the class as they are defined.

Instance Attribute Summary collapse

Attributes inherited from Server

#endpoints, #protocol

Instance Method Summary collapse

Methods inherited from Server

#accept, #on_connect, #on_disconnect, #on_handler_error

Constructor Details

#initialize(*va) ⇒ ProxyServer

Returns a new instance of ProxyServer.



26
27
28
29
30
31
# File 'lib/arpie/proxy.rb', line 26

def initialize *va
  super
  @uuids = {}
  @max_uuids = 100
  @uuid_tracking = true
end

Instance Attribute Details

#interfaceObject

An array containing symbols of method names that the handler should be allowed to call. Defaults to all public instance methods the class defines (wysiwyg). Set this to nil to allow calling of ALL methods, but be warned of the security implications (instance_eval, ..).



17
18
19
# File 'lib/arpie/proxy.rb', line 17

def interface
  @interface
end

#max_uuidsObject

The maximum number of method call results to remember. Defaults to 100, which should be enough for everyone. ;)



24
25
26
# File 'lib/arpie/proxy.rb', line 24

def max_uuids
  @max_uuids
end

#uuid_trackingObject

Set this to false to disable replay protection.



20
21
22
# File 'lib/arpie/proxy.rb', line 20

def uuid_tracking
  @uuid_tracking
end

Instance Method Details

#handle(handler) ⇒ Object

Set a class handler. All public instance methods will be callable over RPC (with a Proxy object) (see attribute interface).



35
36
37
38
39
40
41
# File 'lib/arpie/proxy.rb', line 35

def handle handler
  @handler = handler
  @interface = handler.class.public_instance_methods(false).map {|x|
    x.to_sym
  }
  self
end