MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / ReadNetworkId

Method ReadNetworkId

Source/Engine/Networking/NetworkManager.cpp:167–204  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

165}
166
167void 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
206void NetworkMessage::WriteNetworkName(const StringAnsiView& name)
207{

Calls 6

ReadBytesFunction · 0.85
NetworkKeyFunction · 0.85
CountMethod · 0.45
GetMethod · 0.45
ContainsKeyMethod · 0.45
AddMethod · 0.45

Tested by

no test coverage detected