{
broker* _broker = new broker(); // get yourself a broker
try
{
_broker->init(argc,argv); // initialize orb and boa
universe_world_var p = new universe_world_srv;
_broker->refout("world.ref", p); // write identity
_broker->operator()(); // run the the world
}
catch(corba::exception& ex) { ... }
}
import java.io.*;
import hush.broker; // see broker.java
public class client
{
public static void main(String args[])
{
broker _broker = new broker(true); // true means client only
try
{
_broker.init(args); // init orb
org.omg.CORBA.Object obj = _broker.object("world.ref");
world world = worldHelper.narrow(obj);
if (world == null)
throw new RuntimeException();
System.out.println("Enter 'h' (hello) or 'x' (exit):");
... // do some requests to the world
} catch(...) { ... }
}
};
...
corba_initialize_orb([], _),
factory(F). // gives a handle to the server object
broker(server(M:I)) :-
...
corba_initialize_server([server,server(test),
timeout(infinite)],Server),
... // create server object
G =.. [_Create,_Server,Self],
call(G),
corba_object_to_string(Self,IOR),
open(IORFile,write,Fd), // write reference to file
format(Fd,'string',[IOR]),
close(Fd),
corba_main_loop(Server). // enter main loop
:- use_module(universe). // see universe.pl
:- [broker]. // include broker
main :-
broker(client(universe:F)), // initialize the broker
assert(client(factory(F))),
run.
run :-
h,
ask('What is the state of Clinton s affairs?'),
write('Type h to say hallo, x to quit.'),nl.
ask(X) :-
client(factory(F)),
write(client(ask(X))),nl,
world_ask(F,X),
world_tell(F,R),
write(client(ans(R))),nl.
h :- client(factory(F)), world_hello(F).
q :- client(factory(F)), world_halt(F), halt.
x :- halt.