Class: ScripTTY::Net::EventLoop::ConnectionWrapper
- Inherits:
-
SocketChannelWrapper
- Object
- SocketChannelWrapper
- ScripTTY::Net::EventLoop::ConnectionWrapper
- Defined in:
- lib/scriptty/net/event_loop.rb
Overview
Connection wrapper object.
This object is passed to the block given to EventLoop#on_accept
Direct Known Subclasses
Instance Attribute Summary collapse
-
#master ⇒ Object
readonly
Returns the value of attribute master.
Instance Method Summary collapse
- #close(options = {}) ⇒ Object
-
#on_callback_error(&callback) ⇒ Object
Yield to the given block when another callback raises an exception.
- #on_receive_bytes(&callback) ⇒ Object
- #remote_address ⇒ Object
- #write(bytes, &completion_callback) ⇒ Object
Methods inherited from SocketChannelWrapper
#initialize, #local_address, #on_close
Constructor Details
This class inherits a constructor from ScripTTY::Net::EventLoop::SocketChannelWrapper
Instance Attribute Details
#master ⇒ Object (readonly)
Returns the value of attribute master.
560 561 562 |
# File 'lib/scriptty/net/event_loop.rb', line 560 def master @master end |
Instance Method Details
#close(options = {}) ⇒ Object
574 575 576 577 578 579 580 |
# File 'lib/scriptty/net/event_loop.rb', line 574 def close(={}) if [:hard] @master.send(:close_channel, @channel) else @master.send(:close_channel_gracefully, @channel) end end |
#on_callback_error(&callback) ⇒ Object
Yield to the given block when another callback raises an exception.
562 563 564 565 |
# File 'lib/scriptty/net/event_loop.rb', line 562 def on_callback_error(&callback) @master.send(:set_callback_error_callback, @channel, &callback) self end |
#on_receive_bytes(&callback) ⇒ Object
566 567 568 569 |
# File 'lib/scriptty/net/event_loop.rb', line 566 def on_receive_bytes(&callback) @master.send(:set_on_receive_bytes_callback, @channel, &callback) self end |
#remote_address ⇒ Object
581 582 583 |
# File 'lib/scriptty/net/event_loop.rb', line 581 def remote_address EventLoop.unparse_address(@channel.socket.getRemoteSocketAddress) end |
#write(bytes, &completion_callback) ⇒ Object
570 571 572 573 |
# File 'lib/scriptty/net/event_loop.rb', line 570 def write(bytes, &completion_callback) @master.send(:add_to_write_buffer, @channel, bytes, &completion_callback) self end |