Class: Packet::Pimp

Inherits:
Object
  • Object
show all
Extended by:
Forwardable, ClassHelpers
Includes:
NbioHelper
Defined in:
lib/packet/packet_pimp.rb

Direct Known Subclasses

MetaPimp

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ClassHelpers

iattr_accessor, inheritable_attribute, metaclass

Methods included from NbioHelper

#dump_object, #gen_worker_key, #object_dump, #packet_classify, #read_data, #write_and_schedule, #write_once

Constructor Details

#initialize(lifeline_socket, worker_pid, p_reactor) ⇒ Pimp

Returns a new instance of Pimp.



11
12
13
14
15
16
17
18
# File 'lib/packet/packet_pimp.rb', line 11

def initialize(lifeline_socket,worker_pid,p_reactor)
  @lifeline = lifeline_socket
  @pid = worker_pid
  @reactor = p_reactor
  @signature = Guid.hexdigest
  @outbound_data = []
  pimp_init if self.respond_to?(:pimp_init)
end

Instance Attribute Details

#fd_write_endObject

Returns the value of attribute fd_write_end.



8
9
10
# File 'lib/packet/packet_pimp.rb', line 8

def fd_write_end
  @fd_write_end
end

#lifelineObject

Returns the value of attribute lifeline.



7
8
9
# File 'lib/packet/packet_pimp.rb', line 7

def lifeline
  @lifeline
end

#outbound_dataObject

Returns the value of attribute outbound_data.



9
10
11
# File 'lib/packet/packet_pimp.rb', line 9

def outbound_data
  @outbound_data
end

#pidObject

Returns the value of attribute pid.



7
8
9
# File 'lib/packet/packet_pimp.rb', line 7

def pid
  @pid
end

#reactorObject

Returns the value of attribute reactor.



9
10
11
# File 'lib/packet/packet_pimp.rb', line 9

def reactor
  @reactor
end

#signatureObject

Returns the value of attribute signature.



7
8
9
# File 'lib/packet/packet_pimp.rb', line 7

def signature
  @signature
end

#workersObject

Returns the value of attribute workers.



9
10
11
# File 'lib/packet/packet_pimp.rb', line 9

def workers
  @workers
end

Instance Method Details

#send_data(p_data) ⇒ Object Also known as: do_work

encode the data, before writing to the socket



21
22
23
# File 'lib/packet/packet_pimp.rb', line 21

def send_data p_data
  dump_object(p_data,@lifeline)
end

#send_fd(sock_fd) ⇒ Object



25
26
27
# File 'lib/packet/packet_pimp.rb', line 25

def send_fd sock_fd
  @fd_write_end.send_io(sock_fd)
end