class Nova::Starbound::Client
A client for Nova
.
Constants
- DEFAULT_OPTIONS
The default options when dealing with this class.
Attributes
options[R]
The options that were passed to the client on initialization.
@return [Hash]
protocol[R]
The underlying protocol that powers this client.
@return [Protocol]
Public Class Methods
new(options = {})
click to toggle source
Initialize with the given options.
@param options [Hash]
# File lib/nova/starbound/client.rb, line 29 def initialize(options = {}) @options = DEFAULT_OPTIONS.merge(options) @protocol_options = (@options.delete(:protocol) || {}).dup @protocol = Protocol.new @protocol_options.merge(:type => :client) end
Public Instance Methods
handshake()
click to toggle source
Do the handshake with the server.
@return [void]
# File lib/nova/starbound/client.rb, line 38 def handshake @protocol.socket = socket @protocol.handshake end
socket()
click to toggle source
Create the socket.
@return [Object]
# File lib/nova/starbound/client.rb, line 46 def socket @_socket ||= case options[:type] when :tcp TCPSocket.new(options[:host], options[:port]) when :unix UNIXSocket.new(options[:path]) when :pipe options[:pipe] end end