Class: Rucoa::Server
- Inherits:
-
Object
- Object
- Rucoa::Server
- Defined in:
- lib/rucoa/server.rb
Instance Attribute Summary collapse
- #configuration ⇒ Rucoa::Configuration readonly
- #definition_store ⇒ Rucoa::DefinitionStore readonly
- #shutting_down ⇒ Boolean
- #source_store ⇒ Rucoa::SourceStore readonly
Instance Method Summary collapse
- #finish ⇒ void
-
#initialize(io_in: ::StringIO.new, io_log: ::StringIO.new, io_out: ::StringIO.new) ⇒ Server
constructor
A new instance of Server.
- #responses ⇒ Array<Hash>
- #start ⇒ void
- #write(message) {|response| ... } ⇒ void
Constructor Details
#initialize(io_in: ::StringIO.new, io_log: ::StringIO.new, io_out: ::StringIO.new) ⇒ Server
Returns a new instance of Server.
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/rucoa/server.rb', line 46 def initialize( io_in: ::StringIO.new, io_log: ::StringIO.new, io_out: ::StringIO.new ) @logger = ::Logger.new(io_log) @logger.level = ::Logger::DEBUG @reader = MessageReader.new(io_in) @writer = MessageWriter.new(io_out) @client_response_handlers = {} @configuration = Configuration.new @server_request_id = 0 @shutting_down = false @source_store = SourceStore.new @definition_store = DefinitionStore.new @definition_store.bulk_add(DefinitionArchiver.load) end |
Instance Attribute Details
#configuration ⇒ Rucoa::Configuration (readonly)
35 36 37 |
# File 'lib/rucoa/server.rb', line 35 def configuration @configuration end |
#definition_store ⇒ Rucoa::DefinitionStore (readonly)
38 39 40 |
# File 'lib/rucoa/server.rb', line 38 def definition_store @definition_store end |
#shutting_down ⇒ Boolean
32 33 34 |
# File 'lib/rucoa/server.rb', line 32 def shutting_down @shutting_down end |
#source_store ⇒ Rucoa::SourceStore (readonly)
41 42 43 |
# File 'lib/rucoa/server.rb', line 41 def source_store @source_store end |
Instance Method Details
#finish ⇒ void
This method returns an undefined value.
67 68 69 |
# File 'lib/rucoa/server.rb', line 67 def finish exit(0) end |
#responses ⇒ Array<Hash>
Note:
This method is for testing.
73 74 75 76 77 |
# File 'lib/rucoa/server.rb', line 73 def responses io = @writer.io io.rewind MessageReader.new(io).read.to_a end |
#start ⇒ void
This method returns an undefined value.
80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/rucoa/server.rb', line 80 def start @reader.read do || debug do { kind: :read, message: } end handle() end end |
#write(message) {|response| ... } ⇒ void
This method returns an undefined value.
95 96 97 98 99 100 101 102 103 104 |
# File 'lib/rucoa/server.rb', line 95 def write( , &block ) if block write_server_request(, &block) else write_server_response() end end |