00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00025
00026 #ifndef RemoteClient_H
00027 #define RemoteClient_H
00028
00029
00030 #include "H3DNetworkingUtils/RemoteConnection.h"
00031 #include "H3DNetworkingUtils/RemoteField.h"
00032
00033 #include "H3DNetworkingUtils/sockwrap.h"
00034
00035
00036
00037
00038 template struct __declspec(dllimport) H3D::AutoUpdate <H3D::SFBool>;
00039
00040 namespace H3D {
00041 H3D_VALUE_EXCEPTION( const char *, CantConnect );
00042 }
00043
00044 namespace H3DNetworkingUtils {
00045
00055
00056 class H3D_NETWORKING_UTILS_DLL_SPEC RemoteClient : public RemoteConnection {
00057 public:
00058
00060 struct H3D_NETWORKING_UTILS_DLL_SPEC OpenHandler : public H3D::AutoUpdate<H3D::SFBool> {
00061 virtual void setValue(bool const & val, int id = 0);
00062 virtual void update();
00063 };
00064
00066 RemoteClient( string socket_type = "TCP",
00067 H3D::Inst<H3D::SFString> remoteHost = 0,
00068 H3D::Inst<H3D::SFInt32> remotePort = 0,
00069 H3D::Inst<OpenHandler> open = 0,
00070 H3D::Inst<H3D::SFBool> autoReconnect = 0);
00071
00072 static H3D::H3DNodeDatabase database;
00073
00074 virtual void initialize();
00075
00080 auto_ptr<H3D::SFString> remoteHost;
00081
00086 auto_ptr<H3D::SFInt32> remotePort;
00087
00093 auto_ptr<OpenHandler> open;
00094
00102 auto_ptr<H3D::SFBool> autoReconnect;
00103
00104 protected:
00105
00106 bool openedBefore() const {return opened_once;}
00107
00108
00109 virtual void startClient(string host, int port_number);
00110
00111
00112 void requestRestart() {restart_requested = true;}
00113
00114
00115 virtual void restartClient() = 0;
00116
00117
00118
00119 virtual bool doClosedActions();
00120
00121
00122
00123
00124 virtual void close();
00125
00126
00127 bool restart_requested;
00128
00129 char addr[80];
00130
00131 private:
00132 bool opened_once;
00133 string socket_type;
00134 bool start_called;
00135 };
00136
00137 }
00138
00139 #endif