Class: Pantry::Communication::ReadingSocket
- Inherits:
-
Object
- Object
- Pantry::Communication::ReadingSocket
- Includes:
- Celluloid::ZMQ
- Defined in:
- lib/pantry/communication/reading_socket.rb
Overview
Base class of all sockets that read messages from ZMQ. Not meant for direct use, please use one of the subclasses for specific functionality.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
Instance Method Summary collapse
- #add_listener(listener) ⇒ Object
- #build_socket ⇒ Object
-
#has_source_header? ⇒ Boolean
Some ZMQ socket types include the source as the first packet of a message.
-
#initialize(host, port, security) ⇒ ReadingSocket
constructor
A new instance of ReadingSocket.
- #open ⇒ Object
- #open_socket(socket) ⇒ Object
- #shutdown ⇒ Object
Constructor Details
#initialize(host, port, security) ⇒ ReadingSocket
Returns a new instance of ReadingSocket.
13 14 15 16 17 18 |
# File 'lib/pantry/communication/reading_socket.rb', line 13 def initialize(host, port, security) @host = host @port = port @listener = nil @security = security end |
Instance Attribute Details
#host ⇒ Object (readonly)
Returns the value of attribute host.
11 12 13 |
# File 'lib/pantry/communication/reading_socket.rb', line 11 def host @host end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
11 12 13 |
# File 'lib/pantry/communication/reading_socket.rb', line 11 def port @port end |
Instance Method Details
#add_listener(listener) ⇒ Object
20 21 22 |
# File 'lib/pantry/communication/reading_socket.rb', line 20 def add_listener(listener) @listener = listener end |
#build_socket ⇒ Object
34 35 36 |
# File 'lib/pantry/communication/reading_socket.rb', line 34 def build_socket raise "Implement the socket setup." end |
#has_source_header? ⇒ Boolean
Some ZMQ socket types include the source as the first packet of a message. We need to know if the socket in question does this so we can properly build the Message coming in.
49 50 51 |
# File 'lib/pantry/communication/reading_socket.rb', line 49 def has_source_header? false end |
#open ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/pantry/communication/reading_socket.rb', line 24 def open @socket = build_socket Communication.configure_socket(@socket) @security.configure_socket(@socket) open_socket(@socket) @running = true self.async. end |
#open_socket(socket) ⇒ Object
38 39 40 |
# File 'lib/pantry/communication/reading_socket.rb', line 38 def open_socket(socket) raise "Connect / Bind the socket built in #build_socket" end |
#shutdown ⇒ Object
42 43 44 |
# File 'lib/pantry/communication/reading_socket.rb', line 42 def shutdown @running = false end |