class Nova::Starbound::Protocol
The basic Starbound
protocol.
@todo More testing.
Attributes
options[R]
The options that was passed to this protocol on initialization.
@return [Hash<Symbol, Object>]
state[R]
The current state of the protocol. Known values: :offline
(default), :handshake
, :online
, :closing
.
@return [Symbol]
Public Class Methods
new(options = {})
click to toggle source
Initialize the protocol.
@param options [Hash] the options to initialize the protocol
with.
Calls superclass method
Nova::Starbound::Protocol::Encryption::new
# File lib/nova/starbound/protocol.rb, line 58 def initialize(options = {}) @options = options @state = :offline super() end
Public Instance Methods
close(code = :none)
click to toggle source
Closes the connection.
@return [void]
Calls superclass method
Nova::Starbound::Protocol::Socket#close
# File lib/nova/starbound/protocol.rb, line 68 def close(code = :none) @state = :closing if code send :close, Packet::CloseReasons[code].to_s end super() @state = :offline end
default_behavior()
click to toggle source
Sets up default behaviors within this protocol.
@return [DefaultBehavior]
# File lib/nova/starbound/protocol.rb, line 83 def default_behavior @_default_behavior ||= DefaultBehavior.new(self) end
handshake()
click to toggle source
Perform a handshake with the server. First sets the state to :handshake
.
@return [void]
# File lib/nova/starbound/protocol.rb, line 36 def handshake @state = :handshake thread if options[:type] == :client message = send :protocol_version, Nova::VERSION response = response_to message check_versions response handle_encryption else wait_for_protocol_version handle_server_encryption end @state = :online end