Class: DRb::DRbServer

Inherits:
Object
  • Object
show all
Defined in:
lib/opal/drb/drb_server.rb

Instance Method Summary collapse

Constructor Details

#initialize(uri) ⇒ DRbServer

Returns a new instance of DRbServer.



3
4
5
6
# File 'lib/opal/drb/drb_server.rb', line 3

def initialize(uri)
  @protocol = DRbProtocol.open_server(uri)
  run
end

Instance Method Details



30
31
32
33
# File 'lib/opal/drb/drb_server.rb', line 30

def print_error(e)
  puts e.message
  p e.backtrace
end

#runObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/opal/drb/drb_server.rb', line 12

def run
  @protocol.accept do |client|
    run
    begin
      succ = false
      invoke_method = InvokeMethod.new(self, client)
      succ, result = invoke_method.perform
      print_error(result) unless succ
      client.send_reply(succ, result)
    rescue Exception => e
      print_error(e)
    ensure
      client.close unless succ
      break unless succ
    end
  end
end

#uriObject



8
9
10
# File 'lib/opal/drb/drb_server.rb', line 8

def uri
  @protocol.uri
end