Class: Nova::Starbound::Protocol
- Inherits:
-
Object
- Object
- Nova::Starbound::Protocol
- Includes:
- Encryption, Messages, Socket
- Defined in:
- lib/nova/starbound/protocol.rb,
lib/nova/starbound/protocol/packet.rb,
lib/nova/starbound/protocol/socket.rb,
lib/nova/starbound/protocol/messages.rb,
lib/nova/starbound/protocol/encryption.rb
Overview
More testing.
The basic Starbound protocol.
Defined Under Namespace
Modules: Encryption, Messages, Socket Classes: Packet
Instance Attribute Summary collapse
-
#options ⇒ Hash<Symbol, Object>
readonly
The options that was passed to this protocol on initialization.
-
#state ⇒ Symbol
readonly
The current state of the protocol.
Attributes included from Encryption
Attributes included from Socket
#current_packet_id, #queue, #socket
Instance Method Summary collapse
-
#close(code = :none) ⇒ void
Closes the connection.
-
#default_behavior ⇒ DefaultBehavior
Sets up default behaviors within this protocol.
-
#handshake ⇒ void
Perform a handshake with the server.
-
#initialize(options = {}) ⇒ Protocol
constructor
Initialize the protocol.
Methods included from Messages
#check_versions, #handle_encryption, #handle_server_encryption, #wait_for_protocol_version
Methods included from Socket
#callbacks, #loop, #on, #read, #respond_to, #response_to, #run?, #run_callback, #send, #thread, #threaded?, #write_packet
Constructor Details
#initialize(options = {}) ⇒ Protocol
Initialize the protocol.
58 59 60 61 62 63 |
# File 'lib/nova/starbound/protocol.rb', line 58 def initialize( = {}) = @state = :offline super() end |
Instance Attribute Details
#options ⇒ Hash<Symbol, Object> (readonly)
The options that was passed to this protocol on initialization.
24 25 26 |
# File 'lib/nova/starbound/protocol.rb', line 24 def end |
#state ⇒ Symbol (readonly)
The current state of the protocol. Known values: :offline (default), :handshake, :online, :closing.
30 31 32 |
# File 'lib/nova/starbound/protocol.rb', line 30 def state @state end |
Instance Method Details
#close(code = :none) ⇒ void
This method returns an undefined value.
Closes the connection.
68 69 70 71 72 73 74 75 76 77 78 |
# 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 ⇒ DefaultBehavior
Sets up default behaviors within this protocol.
83 84 85 |
# File 'lib/nova/starbound/protocol.rb', line 83 def default_behavior @_default_behavior ||= DefaultBehavior.new(self) end |
#handshake ⇒ void
This method returns an undefined value.
Perform a handshake with the server. First sets the state to :handshake.
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/nova/starbound/protocol.rb', line 36 def handshake @state = :handshake thread if [:type] == :client = send :protocol_version, Nova::VERSION response = response_to check_versions response handle_encryption else wait_for_protocol_version handle_server_encryption end @state = :online end |