public void interact() { string banner = (string)_remoteconsole.call("get_banner"); Console.WriteLine(banner); const string ps1 = ">>> "; const string ps2 = "... "; bool more = false; while (true) { Console.Write(more ? ps2 : ps1); Console.Out.Flush(); string line = Console.ReadLine(); if (line == null) { // end of input Console.WriteLine(""); break; } var result = (object[])_remoteconsole.call("push_and_get_output", line); if (result[0] != null) { Console.Write(result[0]); } more = (bool)result[1]; } Console.WriteLine("(Remote session ended)"); }
public static void Test() { Console.WriteLine("Testing Pyro flame server (make sure it's running on localhost 9999)..."); Console.WriteLine("Pyrolite version: "+Config.PYROLITE_VERSION); setConfig(); PyroProxy flame=new PyroProxy("localhost",9999,"Pyro.Flame"); Console.WriteLine("builtin:"); using(FlameBuiltin r_max=(FlameBuiltin)flame.call("builtin", "max")) { int maximum=(int)r_max.call(new int[]{22,99,1}); Console.WriteLine("maximum="+maximum); } using(FlameModule r_module=(FlameModule)flame.call("module","socket")) { String hostname=(String)r_module.call("gethostname"); Console.WriteLine("hostname="+hostname); } int sum=(int)flame.call("evaluate", "9+9"); Console.WriteLine("sum="+sum); flame.call("execute", "import sys; sys.stdout.write('HELLO FROM C#\\n')"); using(FlameRemoteConsole console=(FlameRemoteConsole)flame.call("console")) { console.interact(); } }
public static void Test() { Console.WriteLine("Testing Pyro echo server (make sure it's running, with nameserver enabled)..."); Console.WriteLine("Pyrolite version: "+Config.PYROLITE_VERSION); setConfig(); Console.WriteLine("serializer used: {0}", Config.SERIALIZER); if(Config.SERIALIZER==Config.SerializerType.serpent) Console.WriteLine("note that for the serpent serializer, you need to have the Razorvine.Serpent assembly available."); NameServerProxy ns = NameServerProxy.locateNS(null); PyroProxy p = new PyroProxy(ns.lookup("test.echoserver")); // PyroProxy p=new PyroProxy("localhost",9999,"test.echoserver"); Object x=42; Console.WriteLine("echo param:"); PrettyPrint.print(x); Object result=p.call("echo", x); Console.WriteLine("return value:"); PrettyPrint.print(result); String s="This string is way too long. This string is way too long. This string is way too long. This string is way too long. "; s=s+s+s+s+s; Console.WriteLine("echo param:"); PrettyPrint.print(s); result=p.call("echo", s); Console.WriteLine("return value:"); PrettyPrint.print(result); Console.WriteLine("dict test."); IDictionary<string, object> map = new Dictionary<string, object>() { {"value", 42}, {"message", "hello"}, {"timestamp", DateTime.Now} }; result = p.call("echo", map); Console.WriteLine("return value:"); PrettyPrint.print(result); Console.WriteLine("error test."); try { result=p.call("error"); } catch (PyroException e) { Console.WriteLine("Pyro Exception (expected)! {0}",e.Message); Console.WriteLine("Pyro Exception cause: {0}",e.InnerException); Console.WriteLine("Pyro Exception remote traceback:\n>>>\n{0}<<<",e._pyroTraceback); } Console.WriteLine("shutting down the test echo server."); p.call("shutdown"); }
public static void Main(string[] args) { Console.WriteLine("Pyrolite version: "+Config.PYROLITE_VERSION); string hostname=(string)args[0]; int port=int.Parse(args[1]); using(var flame = new PyroProxy(hostname,port,"Pyro.Flame")) { dynamic r_module = flame.call("module","socket"); Console.WriteLine("hostname=" + r_module.call("gethostname")); var console=(FlameRemoteConsole)flame.call("console"); console.interact(); console.close(); } }
public static void Test() { Console.WriteLine("Testing Pyro nameserver connection (make sure it's running with a broadcast server)..."); Console.WriteLine("Pyrolite version: "+Config.PYROLITE_VERSION); setConfig(); NameServerProxy ns=NameServerProxy.locateNS(null); Console.WriteLine("discovered ns at "+ns.hostname+":"+ns.port); ns.ping(); Console.WriteLine("objects registered in the name server:"); IDictionary<string,string> objects = ns.list(null, null); foreach(string key in objects.Keys) { Console.WriteLine(key + " --> " + objects[key]); } ns.register("java.test", new PyroURI("PYRO:JavaTest@localhost:9999"), false); Console.WriteLine("uri=" + ns.lookup("java.test")); Console.WriteLine("using a new proxy to call the nameserver."); PyroProxy p=new PyroProxy(ns.lookup("Pyro.NameServer")); p.call("ping"); int num_removed=ns.remove(null, "java.", null); Console.WriteLine("number of removed entries: {0}",num_removed); try { Console.WriteLine("uri=" + ns.lookup("java.test")); // should fail.... } catch (PyroException x) { // ok Console.WriteLine("got a PyroException (expected): {0}", x.Message); } }
public static Ball FromPyroProxy(PyroProxy proxy) { IDictionary values = (IDictionary)proxy.call("asDict"); int x = (int)values["x"]; int y = (int)values["y"]; int radius = (int)values["radius"]; return new Ball(x, y, radius); }
public static Block FromPyroProxy(PyroProxy proxy) { IDictionary values = (IDictionary)proxy.call("asDict"); int x = (int)values["x"]; int y = (int)values["y"]; int width = (int)values["width"]; int height = (int)values["height"]; return new Block(x, y, width, height); }
public static void Main(string[] args) { using( NameServerProxy ns = NameServerProxy.locateNS(null) ) { using( PyroProxy remoteobject = new PyroProxy(ns.lookup("Your.Pyro.Object")) ) { object result = remoteobject.call("pythonmethod", 42, "hello", new int[]{1,2,3}); string message = (string)result; // cast to the type that 'pythonmethod' returns Console.WriteLine("result message="+message); } } }
public static void Test() { Console.WriteLine("Testing Pyro echo server (make sure it's running on localhost 9999)..."); Console.WriteLine("Pyrolite version: "+Config.PYROLITE_VERSION); setConfig(); PyroProxy p=new PyroProxy("localhost",9999,"test.echoserver"); Object x=42; Console.WriteLine("echo param:"); PrettyPrint.print(x); Object result=p.call("echo", x); Console.WriteLine("return value:"); PrettyPrint.print(result); String s="This string is way too long. This string is way too long. This string is way too long. This string is way too long. "; s=s+s+s+s+s; Console.WriteLine("echo param:"); PrettyPrint.print(s); result=p.call("echo", s); Console.WriteLine("return value:"); PrettyPrint.print(result); Console.WriteLine("error test."); try { result=p.call("error"); } catch (PyroException e) { Console.WriteLine("Pyro Exception (expected)! {0}",e.Message); Console.WriteLine("Pyro Exception cause: {0}",e.InnerException); Console.WriteLine("Pyro Exception remote traceback:\n>>>\n{0}<<<",e._pyroTraceback); } Console.WriteLine("shutting down the test echo server."); p.call("shutdown"); }
public static void Test() { Console.WriteLine("Testing Pyro nameserver connection (make sure it's running with a broadcast server)..."); Console.WriteLine("Pyrolite version: "+Config.PYROLITE_VERSION); setConfig(); Console.WriteLine("serializer used: {0}", Config.SERIALIZER); if(Config.SERIALIZER==Config.SerializerType.serpent) Console.WriteLine("note that for the serpent serializer, you need to have the Razorvine.Serpent assembly available."); using(NameServerProxy ns=NameServerProxy.locateNS(null, hmacKey: hmacKey)) { Console.WriteLine("discovered ns at "+ns.hostname+":"+ns.port); ns.ping(); Console.WriteLine("objects registered in the name server:"); IDictionary<string,string> objects = ns.list(null, null); foreach(string key in objects.Keys) { Console.WriteLine(key + " --> " + objects[key]); } ns.register("java.test", new PyroURI("PYRO:JavaTest@localhost:9999"), false); Console.WriteLine("uri=" + ns.lookup("java.test")); Console.WriteLine("using a new proxy to call the nameserver."); using(PyroProxy p=new PyroProxy(ns.lookup("Pyro.NameServer"))) { p.pyroHmacKey = hmacKey; p.call("ping"); } int num_removed=ns.remove(null, "java.", null); Console.WriteLine("number of removed entries: {0}",num_removed); try { Console.WriteLine("uri=" + ns.lookup("java.test")); // should fail.... } catch (PyroException x) { // ok Console.WriteLine("got a PyroException (expected): {0}", x.Message); } Console.WriteLine("\r\nEnter to exit:"); Console.ReadLine(); } }
public object call(params object[] arguments) { return(_flameserver.call("invokeBuiltin", _builtin, arguments, new Hashtable(0))); }
public static void Test() { Console.WriteLine("Testing Pyro nameserver connection (make sure it's running with a broadcast server)..."); Console.WriteLine("Pyrolite version: "+Config.PYROLITE_VERSION); setConfig(); Console.WriteLine("serializer used: {0}", Config.SERIALIZER); if(Config.SERIALIZER==Config.SerializerType.serpent) Console.WriteLine("note that for the serpent serializer, you need to have the Razorvine.Serpent assembly available."); using(NameServerProxy ns=NameServerProxy.locateNS(null, hmacKey: hmacKey)) { Console.WriteLine("discovered ns at "+ns.hostname+":"+ns.port); ns.ping(); Console.WriteLine("lookup of name server object:"); PyroURI uri = ns.lookup("Pyro.NameServer"); Console.WriteLine(" "+uri); Console.WriteLine("lookup of name server object, with metadata:"); var tmeta = ns.lookup("Pyro.NameServer", true); Console.WriteLine(" uri: "+tmeta.Item1); Console.WriteLine(" meta: "+string.Join(", " ,tmeta.Item2)); var metadata = tmeta.Item2; metadata.Add("updated-by-dotnet-pyrolite"); ns.set_metadata("Pyro.NameServer", metadata); Console.WriteLine("\nobjects registered in the name server:"); IDictionary<string,string> objects = ns.list(null, null); foreach(string key in objects.Keys) { Console.WriteLine(key + " --> " + objects[key]); } Console.WriteLine("\nobjects registered in the name server, with metadata:"); IDictionary<string, Tuple<string, ISet<string>>> objectsm = ns.list_with_meta(null, null); foreach(string key in objectsm.Keys) { var registration = objectsm[key]; Console.WriteLine(key + " --> " + registration.Item1); Console.WriteLine(" metadata: " + string.Join(", ", registration.Item2)); } Console.WriteLine("\nobjects registered having all metadata:"); objects = ns.list(null, null, new []{"blahblah", "class:Pyro4.naming.NameServer"}, null); foreach(string name in objects.Keys) { Console.WriteLine(name + " --> " + objects[name]); } Console.WriteLine("\nobjects registered having any metadata:"); objects = ns.list(null, null, null, new []{"blahblah", "class:Pyro4.naming.NameServer"}); foreach(string name in objects.Keys) { Console.WriteLine(name + " --> " + objects[name]); } Console.WriteLine("\nobjects registered having any metadata (showing it too):"); objectsm = ns.list_with_meta(null, null, null, new []{"blahblah", "class:Pyro4.naming.NameServer"}); foreach(string name in objectsm.Keys) { var entry = objectsm[name]; Console.WriteLine(name + " --> " + entry.Item1); Console.WriteLine(" metadata: " + string.Join(", ", entry.Item2)); } Console.WriteLine(""); ns.register("dotnet.test", new PyroURI("PYRO:DotnetTest@localhost:9999"), false); ns.register("dotnet.testmeta", new PyroURI("PYRO:DotnetTest@localhost:9999"), false, new []{"example", "from-dotnet-pyrolite"}); Console.WriteLine("uri=" + ns.lookup("dotnet.test")); Console.WriteLine("using a new proxy to call the nameserver."); using(PyroProxy p=new PyroProxy(ns.lookup("Pyro.NameServer"))) { p.pyroHmacKey = hmacKey; p.call("ping"); } int num_removed=ns.remove(null, "dotnet.", null); Console.WriteLine("number of removed entries: {0}",num_removed); try { Console.WriteLine("uri=" + ns.lookup("dotnet.test")); // should fail.... } catch (PyroException x) { // ok Console.WriteLine("got a PyroException (expected): {0}", x.Message); } Console.WriteLine("\r\nEnter to exit:"); Console.ReadLine(); } }
public Object call(string attribute, params object[] arguments) { return(flameserver.call("invokeModule", module + "." + attribute, arguments, new Hashtable(0))); }
private String connect() { playfield = new_playfield(); Object result = playfield.call("test", "connected"); string message = (string)result; // cast to the type that 'pythonmethod' returns playfield_panel.Width = (int)playfield.call("get_width"); playfield_panel.Height = (int)playfield.call("get_height"); block = (PyroProxy)playfield.call("create_block"); connected = true; // Pyro Proxies are not thread safe return message; }