Class: Evesync::IPC::Server
- Inherits:
-
Object
- Object
- Evesync::IPC::Server
- Includes:
- Evesync::IPC
- Defined in:
- lib/evesync/ipc/server.rb
Overview
Server is a DRb object, using :port
and :proxy
object to handle requests.
Params
- :proxy
-
all methods go to this object
- :port
-
defines which port which port connect to
Example:
# Setup the server
server = Evesync::IPC::Server(
:port => '8089',
:proxy => SomeHandler.new
)
...
server.start # now it starts recieving requests
...
server.stop # main thread exits
TODO:
* Handle blocks
Instance Attribute Summary collapse
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
Instance Method Summary collapse
-
#initialize(params) ⇒ Server
constructor
A new instance of Server.
- #start ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(params) ⇒ Server
Returns a new instance of Server.
37 38 39 40 41 42 43 |
# File 'lib/evesync/ipc/server.rb', line 37 def initialize(params) check_params_provided(params, %i[port proxy]) port = get_port params ip = params[:ip] || 'localhost' @uri = "druby://#{ip}:#{port}" @proxy = params[:proxy] end |
Instance Attribute Details
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
35 36 37 |
# File 'lib/evesync/ipc/server.rb', line 35 def uri @uri end |
Instance Method Details
#start ⇒ Object
45 46 47 48 |
# File 'lib/evesync/ipc/server.rb', line 45 def start DRb.start_service(@uri, @proxy) self end |
#stop ⇒ Object
50 51 52 53 |
# File 'lib/evesync/ipc/server.rb', line 50 def stop DRb.thread.exit self end |