- Main Page
- Classes
- Files

- Search for |

# RemoteTCPServer.h

Go to the documentation of this file.

    00001 /*****************************
    00002 File:      RemoteTCPServer.h
    00003 Language:   C++ (header)
    00004 Project:    H3DNetworkingUtils
    00005 The contents of this file are subject to the Mozilla Public License
    00006 Version 1.1 (the "License"); you may not use this file except in
    00007 compliance with the License. You may obtain a copy of the License at
    00008 http://www.mozilla.org/MPL/
    00009
    00010 Software distributed under the License is distributed on an "AS IS"
    00011 basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
    00012 License for the specific language governing rights and limitations
    00013 under the License.
    00014
    00015 The Original Code is H3DNetworkingUtils v1.0.
    00016
    00017 The Initial Developer of the Original Code is CSIRO.
    00018 Portions created by the Initial Developer are Copyright (C) 1009 CSIRO. All Rights Reserved.
    00019 Contributor(s):
    00020     Chris Gunn  <Chris.Gunn@csiro.au> <ChrisJGunn@gmail.com>
    00021 ***************************/
    00022
    00025
    00026 #ifndef RemoteTCPServer_H
    00027 #define RemoteTCPServer_H
    00028
    00029 #include "H3DNetworkingUtils/RemoteServer.h"
    00030
    00031 // This next line is needed because H3DAPI.dll instantiates this template but this class does not see the header with
    00032 // the instantiation in it. So without the line, this class would instantiate an identical one and there would
    00033 // be a multiply defined symbol in the link stage.
    00034 template struct __declspec(dllimport) H3D::AutoUpdate <H3D::SFBool>;
    00035
    00036 namespace H3DNetworkingUtils {
    00037
    00050
    00051 class H3D_NETWORKING_UTILS_DLL_SPEC RemoteTCPServer : public RemoteServer {
    00052 public:
    00053
    00055    RemoteTCPServer();
    00056
    00058    virtual ~RemoteTCPServer();
    00059
    00061    static H3D::H3DNodeDatabase database;
    00062
    00063 protected:
    00064
    00066    virtual void startServer(int port_number);
    00067
    00069    virtual void startReceiving();
    00070
    00072    virtual void listeningLoop();
    00073
    00077    struct ListenData {
    00078     int port;
    00079     bool periodic_send;
    00080   };
    00081
    00082   static void listeningThread(void * client_data) {
    00083     static_cast<RemoteTCPServer*>(client_data)->listeningLoop();
    00084   }
    00085
    00087    bool listeningLoopRunning();
    00088
    00090    void setListeningLoopRunning(bool v);
    00091
    00093    void stopListeningThread();
    00094
    00095    bool keepListening();
    00096
    00097 private:
    00098   Thread * listening_threadP;
    00099   ListenData listen_data; // After initial setup, this should only be used by
    00100   // the listening loop.
    00101
    00102   bool periodic_snd; // A copy of the periodic_send field value for use in the
    00103   // listening thread.
    00104
    00105    bool stop_listening_thread;
    00106    bool listening_loop_running;  // This is accessed by several threads. Use listeningLoopRunning() for safe access.
    00107    Mutex listening_loop_lock;
    00108 };
    00109
    00110 }
    00111
    00112 #endif