SPIN Framework

include/spinClientContext.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 __spinClientContext_H
00043 #define __spinClientContext_H
00044 
00045 #include "spinBaseContext.h"
00046 
00047 namespace spin
00048 {
00049 
00050 
00056 class spinClientContext : public spinBaseContext
00057 {
00058     public:
00059 
00060         spinClientContext();
00061         ~spinClientContext();
00062 
00063         bool start();
00064         void debugPrint();
00065         void addCommandLineOptions(osg::ArgumentParser *arguments);
00066         int parseCommandLineOptions(osg::ArgumentParser *arguments);
00067         
00068         lo_server lo_syncServ;
00069 
00070         int pollUpdates();
00071 
00072     //protected:
00076         void subscribe();
00077         
00078 
00079     private:
00080 
00081         // false once we've subscribed to a server in TCP
00082         bool doSubscribe_; 
00083         // address to which messages can be sent over TCP
00084         lo_address lo_serverTCPAddr;
00085 
00086         std::vector<InfoMessage*> serverList;
00087         
00088         // we need to store the TCP address so that the user can override
00089         // it manually. By default, this is filled with getMyIPaddress(),
00090         // but this may be wrong if transmitting across subnets.
00091         std::string recv_tcp_addr;
00092 
00098         static void *spinClientThread(void *arg);
00099 
00101         void createServers();
00107         //static int sceneCallback(const char *path, const char *types, lo_arg **argv, int argc, void *data, void *user_data);
00108 
00113         static int syncCallback(const char *path, const char *types, lo_arg **argv, int argc, void *data, void *user_data);
00114         
00119         static int infoCallback(const char *path, const char *types, lo_arg **argv, int argc, void *data, void *user_data);
00120 
00125         static int tcpCallback(const char *path, const char *types, lo_arg **argv, int argc, void *data, void *user_data);
00126 
00127 
00128 };
00129 
00130 
00131 } // end of namespace spin
00132 
00133 
00134 #endif