Class: OneDrb::Server

Inherits:
Object
  • Object
show all
Defined in:
lib/onedrb.rb

Instance Method Summary collapse

Constructor Details

#initialize(host: '127.0.0.1', port: (49152..65535).to_a.sample.to_s, obj: nil, log: nil) ⇒ Server

Returns a new instance of Server.



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/onedrb.rb', line 62

def initialize(host: '127.0.0.1', port: (49152..65535).to_a.sample.to_s,
                obj: nil, log: nil)

  log.info self.class.to_s + '/initialize: active' if log

  @host, @port, @log = host, port, log

  if obj then
    @obj = obj
  else
    msg = "No object supplied!".error
    puts msg
    raise OneDrbError, msg
  end

  log.info self.class.to_s +'/initialize: completed' if log

end

Instance Method Details

#start ⇒ Object



81
82
83
84
85
86
87
88
# File 'lib/onedrb.rb', line 81

def start()

  @log.info self.class.to_s +'/start: active' if @log
  puts (self.class.to_s + " running on port " + @port).info
  DRb.start_service "druby://#{@host}:#{@port}", @obj
  DRb.thread.join

end