Class: Cod::TcpClient::Connection
- Inherits:
-
Object
- Object
- Cod::TcpClient::Connection
- Defined in:
- lib/cod/tcp_client.rb
Overview
Holds a connection that we don’t create and therefore don’t own. This is the case where a channel is created to communicate back to one of the TcpServers clients: the tcp server manages the back channels, so the created channel is lent its socket only.
Instance Attribute Summary collapse
-
#socket ⇒ Object
readonly
Returns the value of attribute socket.
Instance Method Summary collapse
- #close ⇒ Object
- #established? ⇒ Boolean
-
#initialize(socket, owner) ⇒ Connection
constructor
:nodoc:.
- #read(serializer) ⇒ Object
- #try_connect ⇒ Object
- #write(buffer) ⇒ Object
Constructor Details
#initialize(socket, owner) ⇒ Connection
:nodoc:
255 256 257 258 |
# File 'lib/cod/tcp_client.rb', line 255 def initialize(socket, owner) @owner = owner @socket = socket end |
Instance Attribute Details
#socket ⇒ Object (readonly)
Returns the value of attribute socket.
259 260 261 |
# File 'lib/cod/tcp_client.rb', line 259 def socket @socket end |
Instance Method Details
#close ⇒ Object
271 272 273 |
# File 'lib/cod/tcp_client.rb', line 271 def close @owner.request_close(socket) end |
#established? ⇒ Boolean
262 263 264 |
# File 'lib/cod/tcp_client.rb', line 262 def established? true end |
#read(serializer) ⇒ Object
265 266 267 |
# File 'lib/cod/tcp_client.rb', line 265 def read(serializer) serializer.de(@socket) end |
#try_connect ⇒ Object
260 261 |
# File 'lib/cod/tcp_client.rb', line 260 def try_connect end |
#write(buffer) ⇒ Object
268 269 270 |
# File 'lib/cod/tcp_client.rb', line 268 def write(buffer) @socket.write(buffer) end |