MCPcopy Create free account
hub / github.com/9chu/LuaSTGPlus / UDP_OnDataReceived

Method UDP_OnDataReceived

PerformanceMonitor/TargetProgram.cs:330–426  ·  view source on GitHub ↗
(IAsyncResult ar)

Source from the content-addressed store, hash-verified

328 }
329
330 void UDP_OnDataReceived(IAsyncResult ar)
331 {
332 try
333 {
334 IPEndPoint tEndPoint = new IPEndPoint(IPAddress.Any, 0);
335 Byte[] tBytesReceived = _UdpClient.EndReceive(ar, ref tEndPoint);
336 Dictionary<string, object> tData = Bencode.BencodeUtility.DecodeDictionary(tBytesReceived);
337 if (_Process != null && (long)tData["processId"] == _Process.Id)
338 {
339 Dictionary<string, object> tArgs = (Dictionary<string, object>)tData["args"];
340
341 ResourceType tResourceType;
342 ResourcePoolType tResourcePoolType;
343 string tResourceName;
344 string tResourcePath;
345 float tResourceTime;
346
347 switch ((UdpMessageType)(long)tData["msgType"])
348 {
349 case UdpMessageType.PerformanceUpdate:
350 lock (this)
351 {
352 _FPS = ((long)tArgs["fps"]) / 1000.0f;
353 _Objects = ((long)tArgs["objects"]) / 1000.0f;
354 _FrameTime = ((long)tArgs["frametime"]) / 1000.0f / 1000.0f;
355 _RenderTime = ((long)tArgs["rendertime"]) / 1000.0f / 1000.0f;
356 }
357 break;
358 case UdpMessageType.ResourceLoaded:
359 tResourceType = (ResourceType)(long)tArgs["type"];
360 tResourcePoolType = (ResourcePoolType)(long)tArgs["pool"];
361 tResourceName = Encoding.UTF8.GetString((Byte[])tArgs["name"]);
362 tResourcePath = Encoding.UTF8.GetString((Byte[])tArgs["path"]);
363 tResourceTime = ((long)tArgs["time"] / 1000.0f);
364
365 if (OnResourceLoaded != null)
366 {
367 if (SynchronizeInvoke != null)
368 {
369 SynchronizeInvoke.Invoke((Action)(() =>
370 {
371 OnResourceLoaded(tResourceType, tResourcePoolType, tResourceName, tResourcePath, tResourceTime);
372 }), null);
373 }
374 else
375 OnResourceLoaded(tResourceType, tResourcePoolType, tResourceName, tResourcePath, tResourceTime);
376 }
377 break;
378 case UdpMessageType.ResourceRemoved:
379 tResourceType = (ResourceType)(long)tArgs["type"];
380 tResourcePoolType = (ResourcePoolType)(long)tArgs["pool"];
381 tResourceName = Encoding.UTF8.GetString((Byte[])tArgs["name"]);
382
383 if (OnResourceRemoved != null)
384 {
385 if (SynchronizeInvoke != null)
386 {
387 SynchronizeInvoke.Invoke((Action)(() =>

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected