Class: Backport::Server::Base

Inherits:
Object
  • Object
show all
Includes:
Observable
Defined in:
lib/backport/server/base.rb

Overview

An extendable server class that provides basic start/stop functionality and common callbacks.

Direct Known Subclasses

Interval, Stdio, Tcpip

Instance Method Summary collapse

Instance Method Details

#startObject

Start the server.



13
14
15
16
17
# File 'lib/backport/server/base.rb', line 13

def start
  return if started?
  starting
  @started = true
end

#started?Boolean



29
30
31
# File 'lib/backport/server/base.rb', line 29

def started?
  @started ||= false
end

#startingvoid

This method returns an undefined value.

A callback triggered when a Machine starts running or the server is added to a running machine. Subclasses should override this method to provide their own functionality.



42
# File 'lib/backport/server/base.rb', line 42

def starting; end

#stopObject

Stop the server.



21
22
23
24
25
26
27
# File 'lib/backport/server/base.rb', line 21

def stop
  return if stopped?
  stopping
  @started = false
  changed
  notify_observers self
end

#stopped?Boolean



33
34
35
# File 'lib/backport/server/base.rb', line 33

def stopped?
  !started?
end

#stoppingvoid

This method returns an undefined value.

A callback triggered when the server is stopping. Subclasses should override this method to provide their own functionality.



48
# File 'lib/backport/server/base.rb', line 48

def stopping; end

#tickvoid

This method returns an undefined value.

A callback triggered from the main loop of a running Machine. Subclasses should override this method to provide their own functionality.



55
# File 'lib/backport/server/base.rb', line 55

def tick; end