class Process::Roulette::Controller::ConnectHandler
Handles the CONNECT state of the controller state machine. Connects to the croupier, performs the handshake, and advances to COMMAND state.
Public Class Methods
new(driver)
click to toggle source
# File lib/process/roulette/controller/connect_handler.rb, line 12 def initialize(driver) @driver = driver end
Public Instance Methods
_handshake(socket)
click to toggle source
# File lib/process/roulette/controller/connect_handler.rb, line 28 def _handshake(socket) socket.send_packet(@driver.password || 'OK') packet = socket.wait_with_ping abort 'lost connection' unless packet abort "unexpected packet #{packet.inspect}" unless packet == 'OK' end
run()
click to toggle source
# File lib/process/roulette/controller/connect_handler.rb, line 16 def run puts 'connecting...' socket = TCPSocket.new(@driver.host, @driver.port) Roulette::EnhanceSocket(socket) _handshake(socket) @driver.socket = socket Controller::CommandHandler end