Class: Pixelflut::Client::Socket

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(address, data) ⇒ Socket

Returns a new instance of Socket.



10
11
12
13
14
15
16
17
# File 'lib/pixelflut/client/socket.rb', line 10

def initialize(address, data)
  super(address.ipv6? ? :INET6 : :INET, :STREAM)
  configure
  @addr = ::Socket.pack_sockaddr_in(address.ip_port, address.ip_address)
  @data = data
  @size = data.bytesize
  @state = :not_connected
end

Instance Attribute Details

#stateObject (readonly)

Returns the value of attribute state.



8
9
10
# File 'lib/pixelflut/client/socket.rb', line 8

def state
  @state
end

Instance Method Details

#callObject



19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/pixelflut/client/socket.rb', line 19

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