/**
	 * Stores the given value under the given name and queues it for 
	 * transmission to the server.
	 * 
	 * @param name The name under which to store the given value.
	 * @param type The type of the given value.
	 * @param value The value to store.
	 * @throws TableKeyExistsWithDifferentTypeException Thrown if an 
	 *  entry already exists with the given name and is of a different type.
	 */
	void AbstractNetworkTableEntryStore::PutOutgoing(std::string& name, NetworkTableEntryType* type, EntryValue value){
		{ 
			NTSynchronized sync(LOCK);
			std::map<std::string, NetworkTableEntry*>::iterator index = namedEntries.find(name);
			NetworkTableEntry* tableEntry;
			if(index == namedEntries.end())//if the name does not exist in the current entries
			  {
				tableEntry = new NetworkTableEntry(name, type, value);
				if(addEntry(tableEntry))
				{
					tableEntry->FireListener(listenerManager);
					outgoingReceiver->offerOutgoingAssignment(tableEntry);
				}
			}
			else
			{
				tableEntry = index->second;
				if(tableEntry->GetType()->id != type->id){
					throw TableKeyExistsWithDifferentTypeException(name, tableEntry->GetType());
				}
				
				EntryValue oldValue = tableEntry->GetValue();
				if(!type->areEqual(value, oldValue)){
				  if(updateEntry(tableEntry, (SequenceNumber)(tableEntry->GetSequenceNumber() + 1), value)){
				    outgoingReceiver->offerOutgoingUpdate(tableEntry);
				  }
				
				  tableEntry->FireListener(listenerManager);
				}
			}
		}
	}
void NetworkTableConnection::sendEntryUpdate(NetworkTableEntry& entry) {
	{
		Synchronized sync(WRITE_LOCK);
		sendMessageHeader(FIELD_UPDATE);
		ioStream->write2BytesBE(entry.GetId());
		ioStream->write2BytesBE(entry.GetSequenceNumber());
		entry.SendValue(*ioStream);
	}
}
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);
	}
}