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:



252
253
254
255
# File 'lib/cod/tcp_client.rb', line 252

def initialize(socket, owner)
  @owner = owner
  @socket = socket
end

Instance Attribute Details

#socketObject (readonly)

Returns the value of attribute socket.



256
257
258
# File 'lib/cod/tcp_client.rb', line 256

def socket
  @socket
end

Instance Method Details

#closeObject



268
269
270
# File 'lib/cod/tcp_client.rb', line 268

def close
  @owner.request_close(socket)
end

#established?Boolean

Returns:

  • (Boolean)


259
260
261
# File 'lib/cod/tcp_client.rb', line 259

def established?
  true
end

#read(serializer) ⇒ Object



262
263
264
# File 'lib/cod/tcp_client.rb', line 262

def read(serializer)
  serializer.de(@socket)
end

#try_connectObject



257
258
# File 'lib/cod/tcp_client.rb', line 257

def try_connect
end

#write(buffer) ⇒ Object



265
266
267
# File 'lib/cod/tcp_client.rb', line 265

def write(buffer)
  @socket.write(buffer)
end