Class: ZMachine::Channel
- Inherits:
-
Object
- Object
- ZMachine::Channel
- Defined in:
- lib/zmachine/channel.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#socket ⇒ Object
Returns the value of attribute socket.
Instance Method Summary collapse
-
#can_send? ⇒ Boolean
methods that need to be implemented in sub classes:.
- #close(after_writing = false) ⇒ Object
- #close_after_writing ⇒ Object
-
#initialize ⇒ Channel
constructor
A new instance of Channel.
Constructor Details
#initialize ⇒ Channel
Returns a new instance of Channel.
8 9 10 11 12 |
# File 'lib/zmachine/channel.rb', line 8 def initialize @inbound_buffer = ByteBuffer.allocate(1024 * 1024) @outbound_queue = [] @close_scheduled = false end |
Instance Attribute Details
#socket ⇒ Object
Returns the value of attribute socket.
6 7 8 |
# File 'lib/zmachine/channel.rb', line 6 def socket @socket end |
Instance Method Details
#can_send? ⇒ Boolean
methods that need to be implemented in sub classes:
selectable_fd bind(address, port = nil) bound? accept connect(address, port = nil) connection_pending? finish_connecting connected? read_inbound_data send_data(data) closed? peer write_outbound_data
30 31 32 |
# File 'lib/zmachine/channel.rb', line 30 def can_send? !@outbound_queue.empty? end |
#close(after_writing = false) ⇒ Object
34 35 36 37 38 |
# File 'lib/zmachine/channel.rb', line 34 def close(after_writing = false) ZMachine.logger.debug("zmachine:channel:#{__method__}", channel: self, after_writing: after_writing) if ZMachine.debug @close_scheduled = true @outbound_queue.clear unless after_writing end |
#close_after_writing ⇒ Object
40 41 42 |
# File 'lib/zmachine/channel.rb', line 40 def close_after_writing close(true) end |