Class: PuppetEditorServices::Connection::Base

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

Direct Known Subclasses

Stdio, Tcp

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(server) ⇒ Base

Returns a new instance of Base.



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

def initialize(server)
  @server = server
  @protocol = server.protocol_options[:class].new(self)
end

Instance Attribute Details

#protocolObject (readonly)

Returns the value of attribute protocol.



6
7
8
# File 'lib/puppet_editor_services/connection/base.rb', line 6

def protocol
  @protocol
end

#serverObject (readonly)

Returns the value of attribute server.



6
7
8
# File 'lib/puppet_editor_services/connection/base.rb', line 6

def server
  @server
end

Instance Method Details

#closeObject

Override this method



41
42
43
# File 'lib/puppet_editor_services/connection/base.rb', line 41

def close
  true
end

#close_after_writingObject

Override this method



35
36
37
# File 'lib/puppet_editor_services/connection/base.rb', line 35

def close_after_writing
  true
end

#error?Boolean

Override this method

Returns:

  • (Boolean)


15
16
17
# File 'lib/puppet_editor_services/connection/base.rb', line 15

def error?
  false
end

#idObject



57
58
59
# File 'lib/puppet_editor_services/connection/base.rb', line 57

def id
  object_id.to_s
end

#post_initObject

Override this method if needed



47
48
49
# File 'lib/puppet_editor_services/connection/base.rb', line 47

def post_init
  server.log("Client #{id} has connected to the server")
end

#receive_data(data) ⇒ Object

Shouldn’t need to override this method



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

def receive_data(data)
  @protocol.receive_data(data)
rescue StandardError => e
  server.log("Protocol #{@protocol.class} raised error #{e}: #{e.backtrace}")
end

#send_data(_data) ⇒ Object

Override this method



21
22
23
# File 'lib/puppet_editor_services/connection/base.rb', line 21

def send_data(_data)
  false
end

#unbindObject

Override this method if needed



53
54
55
# File 'lib/puppet_editor_services/connection/base.rb', line 53

def unbind
  server.log("Client #{id} has disconnected from the server")
end