Class: FileProcessingJob::Connection

Inherits:
EM::Connection
  • Object
show all
Defined in:
lib/fpj/connection.rb

Constant Summary collapse

TOKEN =
"_-|fpj|-_"

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Connection

Returns a new instance of Connection.



5
6
7
8
9
# File 'lib/fpj/connection.rb', line 5

def initialize(*args)
  super
  @recv_buffer = BufferedTokenizer.new(TOKEN)
  # set_comm_inactivity_timeout(120)
end

Class Method Details

.loggerObject



11
12
13
# File 'lib/fpj/connection.rb', line 11

def self.logger
  FileProcessingJob.logger
end

Instance Method Details

#loggerObject



15
16
17
# File 'lib/fpj/connection.rb', line 15

def logger
  FileProcessingJob.logger
end

#receive_data(data) ⇒ Object



20
21
22
23
24
# File 'lib/fpj/connection.rb', line 20

def receive_data(data)
  @recv_buffer.extract(data).each do |msg|
    receive_task(msg)
  end
end

#receive_requestObject



30
31
32
# File 'lib/fpj/connection.rb', line 30

def receive_request
  raise "receive_task not overridden by #{self.class.name}"
end

#send_message(data) ⇒ Object



26
27
28
# File 'lib/fpj/connection.rb', line 26

def send_message(data)
  send_data "#{data}#{TOKEN}"
end