Module: UdpServer

Defined in:
lib/server.rb

Instance Method Summary collapse

Instance Method Details

#post_initObject



9
10
11
# File 'lib/server.rb', line 9

def post_init
  CcgLogger::LOGGER.info "#{Time.now.iso8601} |  ++     ... server started"
end

#receive_data(data) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/server.rb', line 13

def receive_data(data)
  puts "1"
  return unless(CcgRunner.instance.valve == :open)
  puts "2"

  ##
  #CcgLogger::LOGGER.info "#{Time.now.iso8601} |  >> raw incoming data: ----------------------"
  #CcgLogger::LOGGER.info data.inspect
  #CcgLogger::LOGGER.info " --------------------------------------------"
  ##
  
  #port, ip = Socket.unpack_sockaddr_in(get_peername)
  #CcgLogger::LOGGER.info "#{Time.now.iso8601} |  >> UdpServer:  sender: #{ip}, #{port}"
  
  # RCA
  rca_dispatching = proc {
    my_dispatcher = CanControlsGateway::OscToRcaDispatcher.new data
    #CcgLogger::LOGGER.info my_dispatcher.event.inspect
    my_dispatcher.dispatch_rca
  }
  rca_callback = proc { |result|
    #if result
    #  CcgLogger::LOGGER.info "#{Time.now.iso8601} |  >> UdpServer:  result is: #{result.inspect}"
    #end
  }
  EventMachine::defer rca_dispatching, rca_callback
end

#unbindObject



41
42
43
# File 'lib/server.rb', line 41

def unbind
  CcgLogger::LOGGER.info "#{Time.now.iso8601} |  -- UdpServer stopped"
end