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

#startvoid

This method returns an undefined value.

Start the server.



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

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

#started?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/backport/server/base.rb', line 31

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.



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

def starting; end

#stopvoid

This method returns an undefined value.

Stop the server.



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

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

#stopped?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/backport/server/base.rb', line 35

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.



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

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.



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

def tick; end