Class: ContentServer::RemoteContentServer

Inherits:
Object
  • Object
show all
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

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

Parameters:

  • addr_info (addr_info)

    address information

  • message (message)

    Content Data



93
94
95
96
97
98
99
100
101
# File 'lib/content_server/remote_content.rb', line 93

def content_requested(addr_info, message)
  # 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_threadrun_server

Open TCP/IP Thread

Returns:

  • (run_server)

    (see #run_server)run TCP server definition in tcp.rb



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