示例#1
0
void NetworkTableConnection::sendEntryUpdate(NetworkTableEntry& entry) {
	{
		Synchronized sync(WRITE_LOCK);
		sendMessageHeader(FIELD_UPDATE);
		ioStream->write2BytesBE(entry.GetId());
		ioStream->write2BytesBE(entry.GetSequenceNumber());
		entry.SendValue(*ioStream);
	}
}
示例#2
0
void NetworkTableConnection::sendEntryAssignment(NetworkTableEntry& entry) {
	{
		Synchronized sync(WRITE_LOCK);
		sendMessageHeader(ENTRY_ASSIGNMENT);
		ioStream->writeString(entry.name);
		ioStream->writeByte(entry.GetType()->id);
		ioStream->write2BytesBE(entry.GetId());
		ioStream->write2BytesBE(entry.GetSequenceNumber());
		entry.SendValue(*ioStream);
	}
}
/**
 * Send all unknown entries in the entry store to the given connection
 * @param connection
 * @throws IOException
 */
void ClientNetworkTableEntryStore::sendUnknownEntries(NetworkTableConnection& connection) {
	{ 
		Synchronized sync(LOCK);
		std::map<std::string, NetworkTableEntry*>::iterator itr;
		for(itr = namedEntries.begin(); itr != namedEntries.end(); itr++)
		{
			NetworkTableEntry* entry = (*itr).second;
			if(entry && entry->GetId()==NetworkTableEntry::UNKNOWN_ID)
				connection.sendEntryAssignment(*entry);
		}
		connection.flush();
	}
}
bool ClientNetworkTableEntryStore::addEntry(NetworkTableEntry* newEntry){
	{
		Synchronized sync(LOCK);
		NetworkTableEntry* entry = (NetworkTableEntry*)namedEntries[newEntry->name];

		if(entry!=NULL){
			if(entry->GetId()!=newEntry->GetId()){
				idEntries.erase(entry->GetId());
				if(newEntry->GetId()!=NetworkTableEntry::UNKNOWN_ID){
					entry->SetId(newEntry->GetId());
					idEntries[newEntry->GetId()] = entry;
				}
			}
			
			entry->ForcePut(newEntry->GetSequenceNumber(), newEntry->GetType(), newEntry->GetValue());
		}
		else{
			if(newEntry->GetId()!=NetworkTableEntry::UNKNOWN_ID)
				idEntries[newEntry->GetId()] = newEntry;
			namedEntries[newEntry->name] = newEntry;
		}
	}
	return true;
}