Sha256: 941290cdf0614faed6e2a458c5a75435a187278e06fbb2ec1dbf0a7cd81a1e31

Contents?: true

Size: 1.3 KB

Versions: 2

Compression:

Stored size: 1.3 KB

Contents

require 'rubygems'
require 'eventmachine'
require 'socket'

require 'osc_to_rca_dispatcher'

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

  def receive_data(data)
    return unless(CcgRunner.instance.valve == :open)

    ##
    #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 {
      begin 
        my_dispatcher = CanControlsGateway::OscToRcaDispatcher.new data
        #CcgLogger::LOGGER.info my_dispatcher.event.inspect
        my_dispatcher.dispatch_rca
      rescue Exception => e
        puts " ## #{e}\n -> #{e.backtrace.join "\n    "}"
      end
    }
    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
  
  def unbind
    CcgLogger::LOGGER.info "#{Time.now.iso8601} |  -- UdpServer stopped"
  end
  
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
tg-can-controls-gateway-0.1.2 lib/server.rb
tg-can-controls-gateway-0.1.1 lib/server.rb