Class: Pixelflut::Client::NonblockSocket

Inherits:
Socket
  • Object
show all
Defined in:
lib/pixelflut/client/socket.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Socket

#connect?, #readline_with_timeout, #write_with_timout

Constructor Details

#initialize(address, data) ⇒ NonblockSocket

Returns a new instance of NonblockSocket.



53
54
55
56
57
58
# File 'lib/pixelflut/client/socket.rb', line 53

def initialize(address, data)
  super(address)
  @state = :not_connected
  @data = data
  @size = data.bytesize
end

Instance Attribute Details

#stateObject (readonly)

Returns the value of attribute state.



51
52
53
# File 'lib/pixelflut/client/socket.rb', line 51

def state
  @state
end

Instance Method Details

#callObject



60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/pixelflut/client/socket.rb', line 60

def call
  case @state
  when :not_connected
    do_connect
  when :wait_connect
    do_wait_for_connect
  when :write
    do_write
  else
    close
    @state = :closed
  end
end