Class: EMRPC::Server

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Server

Returns a new instance of Server.



4
5
6
7
8
9
# File 'lib/emrpc/server.rb', line 4

def initialize(options = {})
  @host   = options[:host]
  @port   = options[:port]
  @object = options[:object]
  @protocol = options[:protocol] || ServerProtocol
end

Instance Attribute Details

#hostObject

Returns the value of attribute host.



3
4
5
# File 'lib/emrpc/server.rb', line 3

def host
  @host
end

#objectObject

Returns the value of attribute object.



3
4
5
# File 'lib/emrpc/server.rb', line 3

def object
  @object
end

#portObject

Returns the value of attribute port.



3
4
5
# File 'lib/emrpc/server.rb', line 3

def port
  @port
end

#protocolObject

Returns the value of attribute protocol.



3
4
5
# File 'lib/emrpc/server.rb', line 3

def protocol
  @protocol
end

Instance Method Details

#runObject



11
12
13
14
15
# File 'lib/emrpc/server.rb', line 11

def run
  EventMachine.start_server(@host, @port, @protocol) do |conn|
    conn.__served_object = @object
  end
end