SPIN Framework

include/spinServerContext.h

00001 // -----------------------------------------------------------------------------
00002 // |    ___  ___  _  _ _     ___                                        _      |
00003 // |   / __>| . \| || \ |   | __>_ _  ___ ._ _ _  ___  _ _ _  ___  _ _ | |__   |
00004 // |   \__ \|  _/| ||   |   | _>| '_><_> || ' ' |/ ._>| | | |/ . \| '_>| / /   |
00005 // |   <___/|_|  |_||_\_|   |_| |_|  <___||_|_|_|\___.|__/_/ \___/|_|  |_\_\   |
00006 // |                                                                           |
00007 // |---------------------------------------------------------------------------|
00008 //
00009 // http://spinframework.sourceforge.net
00010 // Copyright (C) 2009 Mike Wozniewski, Zack Settel
00011 //
00012 // Developed/Maintained by:
00013 //    Mike Wozniewski (http://www.mikewoz.com)
00014 //    Zack Settel (http://www.sheefa.net/zack)
00015 //
00016 // Principle Partners:
00017 //    Shared Reality Lab, McGill University (http://www.cim.mcgill.ca/sre)
00018 //    La Societe des Arts Technologiques (http://www.sat.qc.ca)
00019 //
00020 // Funding by:
00021 //    NSERC/Canada Council for the Arts - New Media Initiative
00022 //    Heritage Canada
00023 //    Ministere du Developpement economique, de l'Innovation et de l'Exportation
00024 //
00025 // -----------------------------------------------------------------------------
00026 //  This file is part of the SPIN Framework.
00027 //
00028 //  SPIN Framework is free software: you can redistribute it and/or modify
00029 //  it under the terms of the GNU Lesser General Public License as published by
00030 //  the Free Software Foundation, either version 3 of the License, or
00031 //  (at your option) any later version.
00032 //
00033 //  SPIN Framework is distributed in the hope that it will be useful,
00034 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00035 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00036 //  GNU Lesser General Public License for more details.
00037 //
00038 //  You should have received a copy of the GNU Lesser General Public License
00039 //  along with SPIN Framework. If not, see <http://www.gnu.org/licenses/>.
00040 // -----------------------------------------------------------------------------
00041 
00042 #ifndef __spinServerContext_H
00043 #define __spinServerContext_H
00044 
00045 #include <map>
00046 #include <string>
00047 #include "spinBaseContext.h"
00048 #include "pocoUtil.h"
00049 
00050 
00051 namespace spin
00052 {
00053 
00060 class spinServerContext : public spinBaseContext
00061 {
00062     public:
00063         spinServerContext();
00064         ~spinServerContext();
00065 
00066         bool start();
00067         void debugPrint();
00068         void addCommandLineOptions(osg::ArgumentParser *arguments);
00069         int parseCommandLineOptions(osg::ArgumentParser *arguments);
00070 
00071         void refreshSubscribers();
00072 
00076         void startSyncThread();
00077 
00083         bool shouldAutoClean() { return autoCleanup_; }
00084 
00085         
00086         //static int sceneCallback(const char *path, const char *types, lo_arg **argv, int argc, void *data, void *user_data);
00087 
00088 #ifdef WITH_POCO
00089         bool applyHTTPMessage(std::string path, const Poco::Net::HTMLForm &form);
00090 #endif
00091         unsigned short getHttpPort() { return httpPort; }
00092     
00093     private:
00094 
00105         static void *spinServerThread(void *arg);
00106 
00108         void createServers();
00109 
00113         static void *syncThread(void *arg);
00114 
00115         bool autoCleanup_;
00116 
00124         //static int infoCallback(const char *path, const char *types, lo_arg **argv, int argc, void *data, void *user_data);
00125 
00126         static int tcpCallback(const char *path, const char *types, lo_arg **argv, int argc, void *data, void *user_data);
00127 
00128         std::map<std::string, lo_address> tcpClientAddrs_;
00129         pthread_t syncThreadID; // id of sync thread
00130         pthread_attr_t syncthreadAttr;
00131     
00132         unsigned short httpPort;
00133 };
00134 
00135 } // end of namespace spin
00136 
00137 #endif