Class: PuppetEditorServices::Connection::Base
- Inherits:
-
Object
- Object
- PuppetEditorServices::Connection::Base
- Defined in:
- lib/puppet_editor_services/connection/base.rb
Instance Attribute Summary collapse
-
#protocol ⇒ Object
readonly
Returns the value of attribute protocol.
-
#server ⇒ Object
readonly
Returns the value of attribute server.
Instance Method Summary collapse
-
#close ⇒ Object
Override this method.
-
#close_after_writing ⇒ Object
Override this method.
-
#error? ⇒ Boolean
Override this method.
- #id ⇒ Object
-
#initialize(server) ⇒ Base
constructor
A new instance of Base.
-
#post_init ⇒ Object
Override this method if needed.
-
#receive_data(data) ⇒ Object
Shouldn’t need to override this method.
-
#send_data(_data) ⇒ Object
Override this method.
-
#unbind ⇒ Object
Override this method if needed.
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.[:class].new(self) end |
Instance Attribute Details
#protocol ⇒ Object (readonly)
Returns the value of attribute protocol.
6 7 8 |
# File 'lib/puppet_editor_services/connection/base.rb', line 6 def protocol @protocol end |
#server ⇒ Object (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
#close ⇒ Object
Override this method
41 42 43 |
# File 'lib/puppet_editor_services/connection/base.rb', line 41 def close true end |
#close_after_writing ⇒ Object
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
15 16 17 |
# File 'lib/puppet_editor_services/connection/base.rb', line 15 def error? false end |
#id ⇒ Object
57 58 59 |
# File 'lib/puppet_editor_services/connection/base.rb', line 57 def id object_id.to_s end |
#post_init ⇒ Object
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 |
#unbind ⇒ Object
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 |