WPILibC++  trunk
ClientConnectionAdapter.h
1 /*
2  * ClientConnectionAdapter.h
3  *
4  * Created on: Nov 2, 2012
5  * Author: Mitchell Wills
6  */
7 
8 #ifndef CLIENTCONNECTIONADAPTER_H_
9 #define CLIENTCONNECTIONADAPTER_H_
10 
12 
13 #include "networktables2/connection/ConnectionAdapter.h"
14 #include "networktables2/IncomingEntryReceiver.h"
15 #include "networktables2/FlushableOutgoingEntryReceiver.h"
16 #include "networktables2/client/ClientNetworkTableEntryStore.h"
17 #include "networktables2/stream/IOStreamFactory.h"
18 #include "networktables2/thread/NTThreadManager.h"
19 #include "networktables2/thread/NTThread.h"
20 #include "networktables2/client/ClientConnectionState.h"
21 #include "networktables2/client/ClientConnectionListenerManager.h"
22 #include "networktables2/connection/ConnectionMonitorThread.h"
23 
24 
32 private:
33  ClientNetworkTableEntryStore& entryStore;
34  IOStreamFactory& streamFactory;
35  NTThreadManager& threadManager;
36 
37  ClientConnectionState* connectionState;
38  ClientConnectionListenerManager& connectionListenerManager;
40  NetworkTableEntryTypeManager& typeManager;
41  NTThread* readThread;
42  ConnectionMonitorThread* monitor;
43  NetworkTableConnection* connection;
44 
45  void gotoState(ClientConnectionState* newState);
46  bool m_IsConnectionClosed; //Keep track of when this is closed to issue reconnect
47 public:
55  bool isConnected();
56 
65  ClientConnectionAdapter(ClientNetworkTableEntryStore& entryStore, NTThreadManager& threadManager, IOStreamFactory& streamFactory, ClientConnectionListenerManager& connectionListenerManager, NetworkTableEntryTypeManager& typeManager);
66  virtual ~ClientConnectionAdapter();
67 
68 
69  /*
70  * Connection management
71  */
75  void reconnect();
76 
80  void close();
85  void close(ClientConnectionState* newState);
86 
87 
88 
90 
91  void ioException(IOException& e);
92 
93  NetworkTableEntry* GetEntry(EntryId id);
94 
95 
96  bool keepAlive();
97 
98  void clientHello(ProtocolVersion protocolRevision);
99 
100  void protocolVersionUnsupported(ProtocolVersion protocolRevision);
101 
102  void serverHelloComplete();
103 
104 
105  void offerIncomingAssignment(NetworkTableEntry* entry);
106  void offerIncomingUpdate(NetworkTableEntry* entry, SequenceNumber sequenceNumber, EntryValue value);
107 
108  void offerOutgoingAssignment(NetworkTableEntry* entry);
109 
110  void offerOutgoingUpdate(NetworkTableEntry* entry);
111  void flush();
112  void ensureAlive();
113 
114 };
115 
116 
117 #endif /* CLIENTCONNECTIONADAPTER_H_ */
ClientConnectionAdapter(ClientNetworkTableEntryStore &entryStore, NTThreadManager &threadManager, IOStreamFactory &streamFactory, ClientConnectionListenerManager &connectionListenerManager, NetworkTableEntryTypeManager &typeManager)
ClientConnectionState * getConnectionState()
void badMessage(BadMessageException &e)
Definition: ITable.h:13