8 #include "networktables2/server/ServerConnectionAdapter.h"
13 if(connectionState!=newState){
14 fprintf(stdout,
"[NT] %p entered connection state: %s\n", (
void*)
this, newState->toString());
16 connectionState = newState;
21 entryStore(_entryStore), transactionReceiver(_transactionReceiver), adapterListener(_adapterListener),
22 connection(stream, typeManager), monitorThread(*this, connection), m_IsAdapterListenerClosed(false) {
28 ServerConnectionAdapter::~ServerConnectionAdapter(){
34 fprintf(stdout,
"[NT] Bad message: %s\n", e.what());
37 adapterListener.
close(*
this,
true);
38 m_IsAdapterListenerClosed=
true;
42 fprintf(stdout,
"[NT] IOException message: %s\n", e.
what());
48 adapterListener.
close(*
this,
false);
49 m_IsAdapterListenerClosed=
true;
59 bool ServerConnectionAdapter::keepAlive() {
60 return !m_IsAdapterListenerClosed;
63 void ServerConnectionAdapter::clientHello(ProtocolVersion protocolRevision) {
65 throw BadMessageException(
"A server should not receive a client hello after it has already connected/entered an error state");
66 if(protocolRevision!=NetworkTableConnection::PROTOCOL_REVISION){
76 void ServerConnectionAdapter::protocolVersionUnsupported(ProtocolVersion protocolRevision) {
77 throw BadMessageException(
"A server should not receive a protocol version unsupported message");
80 void ServerConnectionAdapter::serverHelloComplete() {
85 transactionReceiver.offerIncomingAssignment(entry);
89 transactionReceiver.offerIncomingUpdate(entry, sequenceNumber, value);
93 return entryStore.GetEntry(
id);
114 void ServerConnectionAdapter::flush() {
126 return connectionState;
129 void ServerConnectionAdapter::ensureAlive() {
static ServerConnectionState GOT_CONNECTION_FROM_CLIENT
virtual NTThread * newBlockingPeriodicThread(PeriodicRunnable *r, const char *name)=0
void ioException(IOException &e)
NetworkTableConnection connection
ServerConnectionState * getConnectionState()
virtual void close(ServerConnectionAdapter &connectionAdapter, bool closeStream)=0
ServerConnectionAdapter(IOStream *stream, ServerNetworkTableEntryStore &entryStore, IncomingEntryReceiver &transactionReceiver, ServerAdapterManager &adapterListener, NetworkTableEntryTypeManager &typeManager, NTThreadManager &threadManager)
void sendServerHello(NetworkTableConnection &connection)
void badMessage(BadMessageException &e)
void shutdown(bool closeStream)
static ServerConnectionState CLIENT_DISCONNECTED
static ServerConnectionState CONNECTED_TO_CLIENT