int main(int argc, char ** argv)
{
   CompleteSetupSystem css;

   PrintExampleDescription();

   // Let's enable a bit of debug-output, just to see what the server is doing
   SetConsoleLogLevel(MUSCLE_LOG_DEBUG);

   // This object contains our server's event loop.
   ReflectServer reflectServer;

   // This factory will create a StorageReflectSession object whenever
   // a TCP connection is received on SMART_SERVER_TCP_PORT, and
   // attach the StorageReflectSession to the ReflectServer for use.   
   StorageReflectSessionFactory smartSessionFactory;
   if (reflectServer.PutAcceptFactory(SMART_SERVER_TCP_PORT, ReflectSessionFactoryRef(&smartSessionFactory, false)) != B_NO_ERROR)
   {
      LogTime(MUSCLE_LOG_CRITICALERROR, "Couldn't bind to TCP port %u!  (Perhaps a copy of this program is already running?\n", SMART_SERVER_TCP_PORT);
      return 5;
   }

   // This UDP session will handle the UDP ping pong games
   UDPPingPongSession udpPingPong;
   if (reflectServer.AddNewSession(AbstractReflectSessionRef(&udpPingPong, false)) != B_NO_ERROR)
   {
      LogTime(MUSCLE_LOG_CRITICALERROR, "Couldn't add UDP ping pong session!\n");
      return 5;
   }
   
   LogTime(MUSCLE_LOG_INFO, "example_7_smart_server_wth_udp_pingpong is listening for incoming TCP connections on port %u\n", SMART_SERVER_TCP_PORT);
   LogTime(MUSCLE_LOG_INFO, "Try running one or more instances of example_5_smart_client to connect/chat/subscribe!\n");
   LogTime(MUSCLE_LOG_INFO, "\n");

   // Our server's event loop will run here -- ServerProcessLoop() return until it's time for the server to exit
   if (reflectServer.ServerProcessLoop() == B_NO_ERROR)
   {
       LogTime(MUSCLE_LOG_INFO, "example_7_smart_server_wth_udp_pingpong is exiting normally.\n");
   }
   else LogTime(MUSCLE_LOG_ERROR, "example_7_smart_server_wth_udp_pingpong is exiting due to an error.\n");

   // Make sure our server lets go of all of its sessions and factories
   // before they are destroyed (necessary only because we may have 
   // allocated some of them on the stack rather than on the heap)
   reflectServer.Cleanup();

   return 0;
}
int main(int /*argc*/, char ** /*argv*/) 
{
   CompleteSetupSystem css;  // set up our environment

   ReflectServer server;
   TestSession testSession;        // detects config changes and computer sleeps/wakes
   SomeOtherSession otherSession;  // just to verify that the callbacks get called on other sessions also

   if ((server.AddNewSession(AbstractReflectSessionRef(&testSession, false)) == B_NO_ERROR)&&(server.AddNewSession(AbstractReflectSessionRef(&otherSession, false)) == B_NO_ERROR))
   {
      LogTime(MUSCLE_LOG_INFO, "Beginning Network-Configuration-Change-Detector test... try changing your network config, or plugging/unplugging an Ethernet cable, or putting your computer to sleep.\n");
      if (server.ServerProcessLoop() == B_NO_ERROR) LogTime(MUSCLE_LOG_INFO, "testnetconfigdetect event loop exiting.\n");
                                               else LogTime(MUSCLE_LOG_CRITICALERROR, "testnetconfigdetect event loop exiting with an error condition.\n");
   }
   server.Cleanup();

   return 0;
}