Class: PuppetEditorServices::Connection::Tcp

Inherits:
Base
  • Object
show all
Defined in:
lib/puppet_editor_services/connection/tcp.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#protocol, #server

Instance Method Summary collapse

Methods inherited from Base

#error?, #id, #post_init, #receive_data, #unbind

Constructor Details

#initialize(server, socket) ⇒ Tcp

Returns a new instance of Tcp.



10
11
12
13
# File 'lib/puppet_editor_services/connection/tcp.rb', line 10

def initialize(server, socket)
  super(server)
  @socket = socket
end

Instance Attribute Details

#socketObject

Returns the value of attribute socket.



8
9
10
# File 'lib/puppet_editor_services/connection/tcp.rb', line 8

def socket
  @socket
end

Instance Method Details

#closeObject



28
29
30
31
# File 'lib/puppet_editor_services/connection/tcp.rb', line 28

def close
  server.remove_connection_async(socket)
  true
end

#close_after_writingObject



22
23
24
25
26
# File 'lib/puppet_editor_services/connection/tcp.rb', line 22

def close_after_writing
  socket.flush unless socket.nil?
  server.remove_connection_async(socket)
  true
end

#send_data(data) ⇒ Object



15
16
17
18
19
20
# File 'lib/puppet_editor_services/connection/tcp.rb', line 15

def send_data(data)
  return false if socket.nil?

  socket.write(data)
  true
end