Sha256: da290d30761cce09842dfda2844b3745deb26f73199470986f6709db70287cd1

Contents?: true

Size: 1.9 KB

Versions: 3

Compression:

Stored size: 1.9 KB

Contents

#!/usr/local/bin/ruby

$LOAD_PATH << File.expand_path(File.dirname(__FILE__) + '/../../lib/')

require 'voruby/plastic/plastic'
include VORuby::Plastic

# Define the messages this application can receive.
messages = {
  Messages::VOTABLE_LOAD_FROM_URL => Proc.new { |sender_id, args|
    puts "Received message '#{Messages::VOTABLE_LOAD_FROM_URL}' from #{sender_id}, args = #{args.join(', ')}"
    true
  }
}

# Create the application.
# arg 1 is the list of understood messages and what to do when that message is received,
# arg 2 is the port for the XMLRPC server to listen on (default=8080),
# arg 3 is the path on the XMLRPC server to send messages to (default='/RPC2'),
# arg 4 is the name of the application (default=nil)
# arg 5 is the description of the application (default=nil)
# arg 6 is the URI to the application's icon (default=nil)
# You can also specify the IVORN for the application and the version of Plastic it understands (default=0.5).
@app = Application::Full.new(messages, 8081, '/RPC2',
                            'plastic_ruby', 'A Plastic XMLRPC App running under Ruby',
                            URI.parse('http://www.noao.edu/images/noao_newlogo_top2.gif'))
this_app_id = @app.register()

begin
  # Load a VOTable in every app that supports the ivo://votech.org/votable/loadFromURL message.
  # We're doing it asynchronously i.e. we're not waiting for a response.
  votable_capable = @app.get_message_registered_ids(Messages::VOTABLE_LOAD_FROM_URL)
  @app.request_to_subset_asynch(Messages::VOTABLE_LOAD_FROM_URL,
    ['http://archive.noao.edu/nvo/sim/voquery.php?POS=23.000,2.000&SIZE=7.0000'],
    votable_capable)
    
  # Bring the server to the forefront and wait for incoming messages.
  # To shutdown the server at this point do a Ctrl-C.
  @app.wait_for_requests
rescue StandardError => se
  print "Plasic application error: #{se}"
ensure
  @app.shutdown() # *Always* shutdown the application cleanly.
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
voruby-1.0.1 test/plastic/test.rb
voruby-1.0.2 test/plastic/test.rb
voruby-1.1 test/plastic/test.rb