| 165 | } |
| 166 | |
| 167 | void NetworkMessage::ReadNetworkId(Guid& id) |
| 168 | { |
| 169 | #if USE_NETWORK_KEYS |
| 170 | ScopeLock lock(Keys.Lock); |
| 171 | uint32 index = ReadUInt32(); |
| 172 | if (index != MAX_uint32) |
| 173 | { |
| 174 | if (index < (uint32)Keys.Table.Count()) |
| 175 | { |
| 176 | // Use cached key data |
| 177 | const NetworkKey& k = Keys.Table.Get()[index]; |
| 178 | ASSERT(k.Type == NetworkKey::TypeId); |
| 179 | id = k.Id; |
| 180 | } |
| 181 | else |
| 182 | { |
| 183 | // Incorrect data |
| 184 | // TODO: should we check if message comes before new key arrival? should sender assume that key needs confirmation of receive? |
| 185 | id = Guid::Empty; |
| 186 | } |
| 187 | } |
| 188 | else |
| 189 | { |
| 190 | // Read full data |
| 191 | ReadBytes((uint8*)&id, sizeof(Guid)); |
| 192 | |
| 193 | // When server receives unknown data then turn this into key so connected client will receive it |
| 194 | if (NetworkManager::Mode != NetworkManagerMode::Client && |
| 195 | !Keys.PendingIds.ContainsKey(id) && |
| 196 | !Keys.LookupId.ContainsKey(id)) |
| 197 | { |
| 198 | Keys.PendingIds.Add(id, NetworkKey(id)); |
| 199 | } |
| 200 | } |
| 201 | #else |
| 202 | ReadBytes((uint8*)&id, sizeof(Guid)); |
| 203 | #endif |
| 204 | } |
| 205 | |
| 206 | void NetworkMessage::WriteNetworkName(const StringAnsiView& name) |
| 207 | { |
no test coverage detected