Class: ContentServer::RemoteContentServer
- Inherits:
-
Object
- Object
- ContentServer::RemoteContentServer
- Defined in:
- lib/content_server/remote_content.rb
Overview
Simple TCP server. It connects to server and listens to incoming requests. After receiving the request it sends local content data structure.
Instance Method Summary collapse
-
#content_requested(addr_info, message) ⇒ Object
content_requested.
-
#initialize(port) ⇒ RemoteContentServer
constructor
initializes class variables.
-
#tcp_thread ⇒ run_server
Open TCP/IP Thread.
Constructor Details
#initialize(port) ⇒ RemoteContentServer
initializes class variables
85 86 87 88 |
# File 'lib/content_server/remote_content.rb', line 85 def initialize(port) @tcp_server = Networking::TCPServer.new(port, method(:content_requested)) Log.debug3("initialize RemoteContentServer on port:%s", port) end |
Instance Method Details
#content_requested(addr_info, message) ⇒ Object
content_requested
93 94 95 96 97 98 99 100 101 |
# File 'lib/content_server/remote_content.rb', line 93 def content_requested(addr_info, ) # Send response. Log.info("Content server received content data request") $local_content_data_lock.synchronize{ Log.debug1("Sending content data:%s", $local_content_data) @tcp_server.send_obj($local_content_data) } Log.info('Content server sent content data') end |
#tcp_thread ⇒ run_server
Open TCP/IP Thread
105 106 107 108 |
# File 'lib/content_server/remote_content.rb', line 105 def tcp_thread return @tcp_server.tcp_thread if @tcp_server != nil nil end |