Class: BBFS::ContentServer::ContentDataSender
- Inherits:
-
Object
- Object
- BBFS::ContentServer::ContentDataSender
- Defined in:
- lib/content_server/content_receiver.rb
Instance Method Summary collapse
-
#initialize(host, port) ⇒ ContentDataSender
constructor
A new instance of ContentDataSender.
- #open_socket ⇒ Object
- #send_content_data(content_data) ⇒ Object
Constructor Details
#initialize(host, port) ⇒ ContentDataSender
Returns a new instance of ContentDataSender.
35 36 37 38 39 |
# File 'lib/content_server/content_receiver.rb', line 35 def initialize host, port @host = host @port = port open_socket end |
Instance Method Details
#open_socket ⇒ Object
41 42 43 44 |
# File 'lib/content_server/content_receiver.rb', line 41 def open_socket Log.debug1 "Connecting to content server #{@host}:#{@port}." @tcp_socket = TCPSocket.new(@host, @port) end |
#send_content_data(content_data) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/content_server/content_receiver.rb', line 46 def send_content_data content_data open_socket if @tcp_socket.closed? #Log.debug3 "Data to send: #{content_data}" marshal_data = Marshal.dump(content_data) Log.debug3 "Marshaled size: #{marshal_data.length}." data_size = [marshal_data.length].pack("l") #Log.debug3 "Marshaled data: #{marshal_data}." if data_size.nil? || marshal_data.nil? Log.debug3 'Send data is nil!!!!!!!!' end @tcp_socket.write data_size @tcp_socket.write marshal_data end |