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() { Unpickler u=new Unpickler(); Console.WriteLine("here we go; 1"); var data = PickleUtils.str2bytes("\u0080\u0002carray\narray\nq\u0000U\u0001iq\u0001]q\u0002\u0086q\u0003Rq\u0004."); var result = u.loads(data); PrettyPrint.print(result); Console.WriteLine("here we go; 2"); data=PickleUtils.str2bytes("\u0080\u0003carray\n_array_reconstructor\nq\u0000(carray\narray\nq\u0001X\u0001\u0000\u0000\u0000iq\u0002K\u0008C\u000c\u000f'\u0000\u0000\u00b8\"\u0000\u0000a\u001e\u0000\u0000q\u0003tq\u0004Rq\u0005."); result=u.loads(data); PrettyPrint.print(result); Console.Write("Press any key to continue . . . "); Console.ReadKey(true); }
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"); }
static protected byte[] hmacKey = null; // Encoding.UTF8.GetBytes("foo"); public void Run() { Console.WriteLine("Testing Pyro echo server (make sure it's running, with nameserver enabled)..."); Console.WriteLine("Pyrolite version: " + Config.PYROLITE_VERSION); //Config.SERIALIZER = Config.SerializerType.pickle; 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, hmacKey: hmacKey); using (dynamic p = new PyroProxy(ns.lookup("test.echoserver"))) { p.pyroHmacKey = hmacKey; p.pyroHandshake = "banana"; // non-dynamic way of constructing a proxy is: // PyroProxy p=new PyroProxy("localhost",9999,"test.echoserver"); Console.WriteLine("echo(), param=42:"); Object result = p.echo(42); Console.WriteLine("return value:"); PrettyPrint.print(result); Console.WriteLine("oneway_echo(), param=999:"); result = p.oneway_echo(999); Console.WriteLine("return value:"); PrettyPrint.print(result); // attribute access result = p.verbose; bool verbosity = (bool)result; Console.WriteLine("value of verbose attr: {0}", verbosity); p.verbose = !verbosity; result = p.getattr("verbose"); verbosity = (bool)result; Console.WriteLine("value of verbose attr after toggle: {0}", verbosity); // some more examples 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.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.echo(map); Console.WriteLine("return value:"); PrettyPrint.print(result); // echo a pyro proxy and validate that all relevant attributes are also present on the proxy we got back. Console.WriteLine("proxy test."); result = p.echo(p); PyroProxy p2 = (PyroProxy)result; Console.WriteLine("response proxy: " + p2); Debug.Assert(p2.objectid == "test.echoserver"); Debug.Assert((string)p2.pyroHandshake == "banana"); Debug.Assert(p2.pyroMethods.Contains("echo")); if (p2.pyroHmacKey != null) { string hmac2 = Encoding.UTF8.GetString(p2.pyroHmacKey); Debug.Assert(hmac2 == Encoding.UTF8.GetString(hmacKey)); } Console.WriteLine("remote iterator test."); var iter = p.generator(); foreach (var item in iter) { Console.WriteLine(" got item: " + item); } Console.WriteLine("error test."); try { result = p.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); } try { result = p.error_with_text(); } 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.shutdown(); } }
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); dynamic p = new PyroProxy(ns.lookup("test.echoserver")); // PyroProxy p=new PyroProxy("localhost",9999,"test.echoserver"); Console.WriteLine("echo(), param=42:"); Object result = p.echo(42); Console.WriteLine("return value:"); PrettyPrint.print(result); Console.WriteLine("oneway_echo(), param=999:"); result = p.oneway_echo(999); Console.WriteLine("return value:"); PrettyPrint.print(result); // attribute access result = p.verbose; bool verbosity = (bool)result; Console.WriteLine("value of verbose attr: {0}", verbosity); p.verbose = !verbosity; result = p.getattr("verbose"); verbosity = (bool)result; Console.WriteLine("value of verbose attr after toggle: {0}", verbosity); // some more examples 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.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.echo(map); Console.WriteLine("return value:"); PrettyPrint.print(result); Console.WriteLine("error test."); try { result = p.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.shutdown(); }