Class: Cod::TcpClient::Connection

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#socketObject (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

#closeObject



271
272
273
# File 'lib/cod/tcp_client.rb', line 271

def close
  @owner.request_close(socket)
end

#established?Boolean

Returns:

  • (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_connectObject



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