/home/tetron/hack/vos/apps/tutorials/vostut7server.cc
Go to the documentation of this file.00001 /* Seventh VOS tutorial. Creating your own MetaObjects 00002 00003 This tutorial covers: 00004 - Using our Hello metaobject 00005 - The VOS logging facility 00006 00007 This file (vostut7server.cc) is released into the public domain. No 00008 restrictions are placed on its use, distribution or inclusion into 00009 other works. 00010 */ 00011 00012 // Bring in the definitions of various "Hello" metaobject classes. 00013 #include "vostut7hello.hh" 00014 00015 using namespace VUtil; 00016 using namespace VOS; 00017 00018 #ifdef WIN32 00019 #define sleep _sleep 00020 #endif 00021 00022 int main(int, char**) 00023 { 00024 std::cout << "VOS Tutorial 7 Server\n\n"; 00025 00026 Site site; 00027 site.addSiteExtension(new LocalVipSiteExtension()); 00028 site.setDefaultPolicy("core:accept-all"); 00029 00030 /* The preferred way to write out logging messages for debugging 00031 and user notification is to use the VOS logging facility. This 00032 facility allows for many separate logging channels which can be 00033 individually adjusted to be more or less verbose. The way this 00034 works is simple: each log message consists of the log channel, 00035 the log level, and the message itself. The log level of the 00036 statement is compared against the channel log level, and if the 00037 statement level is equal to or lower than the current level it 00038 is printed out. The log levels run from 0 to 5, where level 0 00039 is reserved for only the absolutely most important messages and 00040 5 is used for debugging that will quickly spam your display 00041 with junk. The default level is 2. Debugging statements 00042 should generally be at level 3 or 4. 00043 00044 Note that if the message doesn't have a good enough log level, 00045 the actual output (eg foo << bar << baz) will never be never 00046 executed, so disabled logging statement are efficiently 00047 overlooked. 00048 */ 00049 LOG("helloserver", 1, "started server at " << site.getURL().getString()); 00050 00051 00052 vRef<Hello> h = site.createVobject<Hello>("hello"); 00053 00054 // Now call the hello() method (same as in the client!) 00055 00056 std::string s = h->hello("I feel like I'm talking to myself."); 00057 00058 00059 LOG("helloserver", 1, "Called hello locally and got this back: '" << s << "'"); 00060 00061 while(true) sleep(1000); 00062 } 00063