MAK RTIspy API Documentation for HLA Evolved
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
rtiAssistantServer.h
Go to the documentation of this file.
1 /****************************************************************************
2  * Copyright (c) 2016 VT MAK
3  * All rights reserved.
4  ****************************************************************************/
5 
9 
10 #pragma once
11 
12 #include <rtiMsConfig.h>
13 
14 #include <map>
15 
16 #include <vlutil/vlBaseMsg.h>
17 #include <vlutil/vlUtil.h>
18 #include <vlutil/vlTime.h>
19 #include <vlutil/vlPrint.h>
20 
22 #include "assistantMsgCbMgr.h"
26 #include "assistantNetStatsEnums.h"
27 
29 typedef void (*DtAssistantSocketAdditionCb)(int compId, void* usr);
30 typedef void (*DtAssistantSocketRemovalCb)(int compId, const MAKRti::DtString& reason, void* usr);
31 class DtAssistantSocketAdditionCbInfo;
32 class DtAssistantSocketRemovalCbInfo;
33 typedef std::list<DtAssistantSocketAdditionCbInfo*> DtAssistantSocketAdditionCallbackList;
34 typedef std::list<DtAssistantSocketRemovalCbInfo*> DtAssistantSocketRemovalCallbackList;
35 
36 class DtTcpMsgSocketMgr;
37 class DtTcpMsgSocket;
38 
46 {
47 
48 public:
50  DtRtiAssistantServer( DtNotifyLevelType level ,
51  int port = DtASSISTANT_DEFAULT_PORT,
52  const MAKRti::DtInetAddr& networkInterface = MAKRti::DtInetAddr() );
53 
55  virtual ~DtRtiAssistantServer();
56 
57 public:
58 
60  bool isOk() const;
61 
64  virtual void addMsgCallback(DtAssistantMsgKind msgKind, DtAssistantMsgCbMgr::DtCallbackFcn fcn,
65  void *usr );
66  virtual void removeMsgCallback(DtAssistantMsgKind msgKind, DtAssistantMsgCbMgr::DtCallbackFcn fcn,
67  void *usr );
68  virtual void addWildcardMsgCallback(DtAssistantMsgCbMgr::DtCallbackFcn fcn,
69  void *usr );
70  virtual void removeWildcardMsgCallback(DtAssistantMsgCbMgr::DtCallbackFcn fcn,
71  void *usr );
72 
75  virtual void addSocketAdditionCallback(DtAssistantSocketAdditionCb cb, void* usr);
76  virtual void removeSocketAdditionCallback(DtAssistantSocketAdditionCb cb, void* usr);
77  virtual void addSocketRemovalCallback(DtAssistantSocketRemovalCb cb, void* usr);
78  virtual void removeSocketRemovalCallback(DtAssistantSocketRemovalCb cb, void* usr);
79 
82  virtual bool tick( double timeout = 0 );
83 
85  virtual unsigned int numConnections() const;
86 
88  virtual void sendMsgOnConn( int compId, const DtAssistantMsg& msg );
89 
91  virtual void sendBroadcast( const DtAssistantMsg& msg );
92 
94  virtual void sendConnMsg( int compId, bool disconnect = false,
95  const MAKRti::DtString& display = MAKRti::DtString::nullString() );
96 
99  virtual void sendConnRespMsg( int compId, const DtRtiConnectionInfoDataPair& conn,
100  const DtRtiConnectionConfigurationInfo& config, bool accepted );
101 
103  virtual void sendLicRespMsg( int compId, bool runUnlicensed,
104  const MAKRti::DtString& server, int port, bool accepted );
105 
107  virtual void sendAssistantCommandResponseMsg(
108  int compId, const MAKRti::DtString& formattedData );
109 
111  virtual void sendForwarderConnectMsg(
112  int compId, const MAKRti::DtString& targetHost,
113  const MAKRti::DtInetAddr& targetAddress, int targetPort);
114 
116  virtual void sendNtfyLvlUpdateMsg( int compId, DtNotifyLevelType notifyLevel );
117 
120  virtual void sendLatencyTestRequestMsg( int compId, bool runTest, bool continuous,
121  bool shouldHalt, bool observing, unsigned int interactionPeriod,
122  unsigned int numInteractions, unsigned int payloadBytes,
123  unsigned long federationHandle = 0,
124  unsigned long initFedHandle = 0 );
125 
128  virtual void sendNetworkTestEnableMsg( int compId, int federationHdl, bool enable );
129 
131  virtual void sendLogEnableMsg( int compId, bool enable );
132 
135  virtual void sendObserveRtiexecMsg( int compId, bool isObserved,
136  unsigned int timeStateIntervalMs );
137 
140  virtual void sendObserveRtiexecLogMsg( int connId, bool isObserved );
141 
144  virtual void sendObserveRtiForwarderMsg( int compId, bool isObserved,
145  unsigned int timeStateIntervalMs, int defunctRemovalTime );
146 
149  virtual void sendSingleObserveRtiExecMsg( int compId );
150 
153  virtual void sendSingleObserveForwarderMsg( int compId );
154 
156  virtual void sendFederateResignMsg( int compId, int federationHdl, int federateHdl );
157 
159  virtual void sendFederationDestroyMsg( int compId, int federationHdl );
160 
162  virtual void sendDeleteFederateMsg( int compId, DtU16 fedexHandle, DtU16 fedHandle );
163 
165  virtual void sendRidParamsRequestMsg( int compId );
166 
169  virtual void sendLogRequestMsg( int compId, unsigned maxLogSize );
170 
173  virtual void sendNetStatsObservationRequestMsg( DtAssistantObservationType observationType,
174  int compId, bool observe = false, unsigned int interval = 0);
175 
178  virtual void sendExitMsg( int compId = -1 );
179 
182  virtual void sendDoNotWaitForForwardersMsg( int compId );
183 
186  virtual void forwardMsg( const DtAssistantMsg& msg );
187 
189  virtual void sendSignalTickIntervalMsg( int compId, float signalTickInterval );
190 
193  virtual int currentCompId() const;
194 
196  virtual void closeConn( int compId );
197 
199  virtual int port() const;
200 
202  virtual DtU32 maxMsgSize() const;
203 
205  static void tcpSocketAdditionCb( DtTcpMsgSocket* sock, void* usr );
206  static void tcpSocketRemovalCb( DtTcpMsgSocket* sock, void* usr );
207 
208  virtual const DtInetAddr& getNetworkAddr();
209 
210 #ifdef DtDIAGNOSTIC
211 
212  void enableMsgDiagnostics( bool enable );
213 
214 #endif
215 
216 protected:
217 
219  virtual void sendMsg( DtTcpMsgSocket* sock, const DtAssistantMsg& msg );
220 
222  virtual void testConnections();
223 
226  virtual bool readAndProcess( DtTime maxTimePerSocket );
227 
229  virtual void tcpSocketAdditionCb( DtTcpMsgSocket* sock );
230  virtual void tcpSocketRemovalCb( DtTcpMsgSocket* sock );
231 
233  virtual DtUniquePtr<DtAssistantMsg> netRead( DtTcpMsgSocket* sock, int *retCode) const;
234 
236  virtual void setMsgFactory(DtAssistantMessageFactory* fact);
237  virtual DtAssistantMessageFactory* msgFactory() const;
238 
239 private:
242  DtRtiAssistantServer& operator=( const DtRtiAssistantServer& );
243 
244 protected:
245 
247  typedef std::map< int, DtTcpMsgSocket* > CompIdToSocketMap;
248  typedef std::map< DtTcpMsgSocket*, int > SocketToCompIdMap;
249 
252 
255 
258 
261 
264 
268 
270  unsigned int myPort;
271 
273  DtClock myClock;
274 
277 
280 
282  DtUniquePtr<DtTcpMsgSocketMgr> mySocketMgr;
283 
285  MAKRti::DtInetAddr myNetworkInterface;
286 
288  std::list< DtTcpMsgSocket* > mySocketsToDisconnect;
289 
292 
294  std::map<int, MAKRti::DtString> myDisconnectReasons;
295 
299 
301  unsigned myNumMsgsSent;
302 
305 
306 #ifdef DtDIAGNOSTIC
307  bool myDiagnosticsEnabled;
308 #endif
309 
310 };
DtAssistantMsgCbMgr myMsgCbMgr
Message callback manager.
Definition: rtiAssistantServer.h:291
std::list< DtAssistantSocketAdditionCbInfo * > DtAssistantSocketAdditionCallbackList
Definition: rtiAssistantServer.h:32
void(* DtAssistantSocketRemovalCb)(int compId, const MAKRti::DtString &reason, void *usr)
Definition: rtiAssistantPeer.h:77
DtAssistantMessageFactory * myMessageFactory
The message factory.
Definition: rtiAssistantServer.h:260
DtAssistantDfltMsgFactory myDefaultMessageFactory
Default message factory.
Definition: rtiAssistantServer.h:263
unsigned int myPort
Port to which RTI components may connect.
Definition: rtiAssistantServer.h:270
std::list< DtTcpMsgSocket * > mySocketsToDisconnect
List of sockets to be disconnected before next read.
Definition: rtiAssistantServer.h:288
std::map< DtTcpMsgSocket *, int > SocketToCompIdMap
Definition: rtiAssistantServer.h:248
unsigned myNumMsgsReceived
Total messages received.
Definition: rtiAssistantServer.h:304
SocketToCompIdMap myIdsByConnection
Map of component IDs by connection.
Definition: rtiAssistantServer.h:251
DtAssistantSocketRemovalCallbackList myRemovalCallbacks
Definition: rtiAssistantServer.h:298
This file contains the declaration of DtRtiConnectionInfo.
std::pair< DtRtiConnectionInfo, DtRtiAssociatedConnectionData > DtRtiConnectionInfoDataPair
Pair of connection with associated data.
Definition: assistantConnectionInfo.h:29
Definition: tcpMsgSocketMgr.h:43
Contains the DtRtiConnectionConfigurationInfo class declaration.
DtTime myTimeToTestConnections
Next time to test connections.
Definition: rtiAssistantServer.h:279
DtAssistantMsgKind
Definition: assistantMsg.h:53
Base class for assistant Messages.
Definition: assistantMsg.h:153
std::list< DtAssistantSocketRemovalCbInfo * > DtAssistantSocketRemovalCallbackList
Definition: rtiAssistantServer.h:34
DtTime myConnTestInterval
Interval at which connections should be tested.
Definition: rtiAssistantServer.h:276
unsigned myNumMsgsSent
Total messages sent.
Definition: rtiAssistantServer.h:301
DtTcpMsgSocket * myCurrentSocket
The socket on which the current message being processed was received.
Definition: rtiAssistantServer.h:267
#define DT_DLL_ASSISTANT
Default – Unix or Win32 static.
Definition: rtiMsConfig.h:150
#define DtASSISTANT_DEFAULT_PORT
Definition: assistantMsg.h:30
DtAssistantObservationType
Definition: assistantNetStatsEnums.h:8
Instances of DtAssistantDfltMsgFactory are used to create DtRtiMsgs.
Definition: assistantDefaultMsgFact.h:20
MAKRti::DtInetAddr myNetworkInterface
Network Interface.
Definition: rtiAssistantServer.h:285
Manages the server connections of the RTI Assistant.
Definition: rtiAssistantServer.h:45
void(* DtAssistantSocketAdditionCb)(int compId, void *usr)
Socket addition and removal callback signatures.
Definition: rtiAssistantPeer.h:76
Stores the information on an RTI configuration known by the Assistant.
Definition: assistantConnectionConfigurationInfo.h:61
DtClock myClock
Clock for timeouts.
Definition: rtiAssistantServer.h:273
The DtTcpMsgSocket class provides an address family independent TCP socket that handles RTI messages...
Definition: tcpMsgSocket.h:40
std::map< int, MAKRti::DtString > myDisconnectReasons
List of reasons for socket disconnects.
Definition: rtiAssistantServer.h:294
int myNextCompId
Next component ID to use.
Definition: rtiAssistantServer.h:257
std::map< int, DtTcpMsgSocket * > CompIdToSocketMap
Maps of the connections and component IDs.
Definition: rtiAssistantServer.h:247
DT_DLL_ASSISTANT DtMessageCallbackManager< DtAssistantMsg, DtAssistantMsgKind > DtAssistantMsgCbMgr
Definition: assistantMsgCbMgr.h:18
DtUniquePtr< DtTcpMsgSocketMgr > mySocketMgr
Manager for the sockets.
Definition: rtiAssistantServer.h:282
DtAssistantSocketAdditionCallbackList myAdditionCallbacks
Lists of pointers to socket addition and socket removal callbacks.
Definition: rtiAssistantServer.h:297
CompIdToSocketMap myConnectionsById
Map of connections by component ID.
Definition: rtiAssistantServer.h:254

Document ID: Generated on Sun Jul 20 16:15:30 EDT 2025 from SVN revision 277985
Copyright © 2005-2025 MAK Technologies Inc. All Rights Reserved (www.mak.com)