| 231 | } |
| 232 | |
| 233 | void NetworkMessage::ReadNetworkName(StringAnsiView& name) |
| 234 | { |
| 235 | #if USE_NETWORK_KEYS |
| 236 | ScopeLock lock(Keys.Lock); |
| 237 | uint32 index = ReadUInt32(); |
| 238 | if (index != MAX_uint32) |
| 239 | { |
| 240 | if (index < (uint32)Keys.Table.Count()) |
| 241 | { |
| 242 | // Use cached key data |
| 243 | const NetworkKey& k = Keys.Table.Get()[index]; |
| 244 | ASSERT(k.Type == NetworkKey::TypeName); |
| 245 | name = k.Name; |
| 246 | } |
| 247 | else |
| 248 | { |
| 249 | // Incorrect data |
| 250 | // TODO: should we check if message comes before new key arrival? should sender assume that key needs confirmation of receive? |
| 251 | name = StringAnsiView::Empty; |
| 252 | } |
| 253 | } |
| 254 | else |
| 255 | { |
| 256 | // Read full data |
| 257 | name = ReadStringAnsi(); |
| 258 | |
| 259 | // When server receives unknown data then turn this into key so connected client will receive it |
| 260 | if (NetworkManager::Mode != NetworkManagerMode::Client && |
| 261 | !Keys.PendingNames.ContainsKey(name) && |
| 262 | !Keys.LookupName.ContainsKey(name)) |
| 263 | { |
| 264 | StringAnsiView newName = CloneAllocName(name); |
| 265 | Keys.PendingNames.Add(newName, NetworkKey(newName)); |
| 266 | } |
| 267 | } |
| 268 | #else |
| 269 | name = ReadStringAnsi(); |
| 270 | #endif |
| 271 | } |
| 272 | |
| 273 | void OnNetworkMessageHandshake(NetworkEvent& event, NetworkClient* client, NetworkPeer* peer) |
| 274 | { |
no test coverage detected