diff options
Diffstat (limited to 'cs/demo/book/simple_filesystem/Server.cs')
-rw-r--r-- | cs/demo/book/simple_filesystem/Server.cs | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/cs/demo/book/simple_filesystem/Server.cs b/cs/demo/book/simple_filesystem/Server.cs index 9a324b2e97a..55e972732cc 100644 --- a/cs/demo/book/simple_filesystem/Server.cs +++ b/cs/demo/book/simple_filesystem/Server.cs @@ -23,37 +23,46 @@ public class Server { public override int run(string[] args) { + // // Terminate cleanly on receipt of a signal // shutdownOnInterrupt(); + // // Create an object adapter. // - Ice.ObjectAdapter adapter = communicator().createObjectAdapterWithEndpoints( - "SimpleFilesystem", "default -h 127.0.0.1 -p 10000"); + Ice.ObjectAdapter adapter = + communicator().createObjectAdapterWithEndpoints("SimpleFilesystem", "default -h 127.0.0.1 -p 10000"); + // // Create the root directory (with name "/" and no parent) // DirectoryI root = new DirectoryI(communicator(), "/", null); root.activate(adapter); + // // Create a file called "README" in the root directory // FileI file = new FileI(communicator(), "README", root); string[] text; text = new string[]{ "This file system contains a collection of poetry." }; - try { + try + { file.write(text); - } catch (GenericError e) { + } + catch(GenericError e) + { Console.Error.WriteLine(e.reason); } file.activate(adapter); + // // Create a directory called "Coleridge" in the root directory // DirectoryI coleridge = new DirectoryI(communicator(), "Coleridge", root); coleridge.activate(adapter); + // // Create a file called "Kubla_Khan" in the Coleridge directory // file = new FileI(communicator(), "Kubla_Khan", coleridge); @@ -62,23 +71,30 @@ public class Server "Where Alph, the sacred river, ran", "Through caverns measureless to man", "Down to a sunless sea." }; - try { + try + { file.write(text); - } catch (GenericError e) { + } + catch(GenericError e) + { Console.Error.WriteLine(e.reason); } file.activate(adapter); + // // All objects are created, allow client requests now // adapter.activate(); + // // Wait until we are done // communicator().waitForShutdown(); - if (interrupted()) + if(interrupted()) + { Console.Error.WriteLine(appName() + ": terminating"); + } return 0; } |