use lib '/path/to/your/moduletree';
my $rpc = UR::Service::JsonRpcServer->create(host => 'localhost',
port => '8080',
api_root => 'URapi',
docroot => '/html/pages/path',
DescriptionThis is a class containing an implementation of a JSON-RPC server to respond to requests involving UR-based namespaces and their objects. It uses Net::HTTPServer as the web server back-end library.
Incoming requests are divided into two major categories:
ConstructorThe constructor takes the following named parameters:
- The hostname to listen on. This can be an ip address, host name, or undef. The default value is '0.0.0.0'. This argument is passed along verbatim to the Net::HTTPServer constructor.
- The TCP port to listen on. The default value is 8080. This argument is passed along verbatim to the Net::HTTPServer constructor.
- The root path that the http server will listen for requests on. The constructor registers two paths with the Net::HTTPServer with RegisterRegex() for /"api_root"/class/* and /"api_root"/obj/* to respond to class and instance metod calls.
All other arguments are passed along to the Net::HTTPServer constructor.
- A wrapper to the Net::HTTPServer Process() method. With no arguments, this call will block forever from the perspective of the caller, and process all http requests coming in. You can optionally pass in a timeout value in seconds, and it will respond to requests for the given number of seconds before returning.
var UR = new URInterface('http://localhost:8080/URApi/'); // Connect to the server var FooThingy = UR.get_class('Foo::Thingy'); // Get the class object for Foo::Thingy var thingy = FooThingy.get(1234); // Retrieve an instance with ID 1234 var result = thingy.call('method_name', 1, 2, 3); // Call $thingy->method_name(1,2,3) on the server