8 #include "networktables2/client/ClientConnectionAdapter.h"
9 #include "networktables2/util/System.h"
14 if(connectionState!=newState){
15 fprintf(stdout,
"[NT] %p entered connection state: %s\n", (
void*)
this, newState->toString());
23 connectionState = newState;
33 return connectionState;
51 entryStore(_entryStore),
52 streamFactory(_streamFactory),
53 threadManager(_threadManager),
54 connectionListenerManager(_connectionListenerManager),
55 typeManager(_typeManager),
61 ClientConnectionAdapter::~ClientConnectionAdapter()
113 connection->SetIOStream(stream);
114 m_IsConnectionClosed=
false;
119 connection->sendClientHello();
145 connection->SetIOStream(NULL);
147 m_IsConnectionClosed=
true;
171 return entryStore.GetEntry(
id);
175 bool ClientConnectionAdapter::keepAlive() {
179 void ClientConnectionAdapter::clientHello(ProtocolVersion protocolRevision) {
183 void ClientConnectionAdapter::protocolVersionUnsupported(ProtocolVersion protocolRevision) {
188 void ClientConnectionAdapter::serverHelloComplete() {
198 throw BadMessageException(
"A client should only receive a server hello complete once and only after it has connected to the server");
202 void ClientConnectionAdapter::offerIncomingAssignment(
NetworkTableEntry* entry) {
203 entryStore.offerIncomingAssignment(entry);
206 entryStore.offerIncomingUpdate(entry, sequenceNumber, value);
209 void ClientConnectionAdapter::offerOutgoingAssignment(
NetworkTableEntry* entry) {
214 connection->sendEntryAssignment(*entry);
226 connection->sendEntryUpdate(*entry);
232 void ClientConnectionAdapter::flush() {
235 if(connection!=NULL) {
244 void ClientConnectionAdapter::ensureAlive() {
247 if ((connection!=NULL)&&(!m_IsConnectionClosed)) {
249 connection->sendKeepAlive();
virtual NTThread * newBlockingPeriodicThread(PeriodicRunnable *r, const char *name)=0
virtual IOStream * createStream()=0
static ClientConnectionState DISCONNECTED_FROM_SERVER
static ClientConnectionState IN_SYNC_WITH_SERVER
virtual void FireConnectedEvent()=0
ClientConnectionAdapter(ClientNetworkTableEntryStore &entryStore, NTThreadManager &threadManager, IOStreamFactory &streamFactory, ClientConnectionListenerManager &connectionListenerManager, NetworkTableEntryTypeManager &typeManager)
void sendUnknownEntries(NetworkTableConnection &connection)
ClientConnectionState * getConnectionState()
void badMessage(BadMessageException &e)
static ClientConnectionState CONNECTED_TO_SERVER
virtual void FireDisconnectedEvent()=0
void ioException(IOException &e)