Class: UV::TcpConnection
- Inherits:
-
Connection
- Object
- Connection
- UV::TcpConnection
- Defined in:
- lib/uv-rays/connection.rb
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from Connection
Instance Method Summary collapse
- #close_connection(after_writing = false) ⇒ Object
- #keepalive(raw_time) ⇒ Object
-
#on_close ⇒ Object
user to define.
-
#on_connect(transport) ⇒ Object
user to define.
- #stream_file(filename, type = :raw) ⇒ Object
- #write(data) ⇒ Object
Methods inherited from Connection
#initialize, #on_read, #pause, #paused?, #post_init, #resume
Constructor Details
This class inherits a constructor from UV::Connection
Instance Method Details
#close_connection(after_writing = false) ⇒ Object
70 71 72 73 74 75 76 |
# File 'lib/uv-rays/connection.rb', line 70 def close_connection(after_writing = false) if after_writing @transport.shutdown else @transport.close end end |
#keepalive(raw_time) ⇒ Object
88 89 90 91 92 93 94 95 |
# File 'lib/uv-rays/connection.rb', line 88 def keepalive(raw_time) time = raw_time.to_i if time.to_i <= 0 @transport.disable_keepalive else @transport.enable_keepalive(time) end end |
#on_close ⇒ Object
user to define
100 101 |
# File 'lib/uv-rays/connection.rb', line 100 def on_close # user to define end |
#on_connect(transport) ⇒ Object
user to define
97 98 |
# File 'lib/uv-rays/connection.rb', line 97 def on_connect(transport) # user to define end |
#stream_file(filename, type = :raw) ⇒ Object
78 79 80 81 82 83 84 85 86 |
# File 'lib/uv-rays/connection.rb', line 78 def stream_file(filename, type = :raw) file = @loop.file(filename, File::RDONLY) file.progress do # File is open and available for reading file.send_file(@transport, type).finally do file.close end end return file end |
#write(data) ⇒ Object
66 67 68 |
# File 'lib/uv-rays/connection.rb', line 66 def write(data) @transport.write(data) end |