Example #1
0
 protected override Task RunAsync(UdpResult result, UdpShared udpshared)
 {
     return(Task.Factory.StartNew(() =>
     {
         if (!udpshared.entities.ContainsKey(result.endPoint))
         {
             Entity e = udpshared.world.AddEntity();
             e.Add(new UdpField(result.endPoint));
             udpshared.entities.Add(result.endPoint, e.Id);
             //DebugUtility.Log($"Accept::RunAsync ID={e.Id}");
             udpshared.SendHead(result.endPoint, ConDefine.onConnect);
         }
     }));
 }
Example #2
0
 protected override Task RunAsync(UdpResult result, UdpShared udpshared)
 {
     return(Task.Factory.StartNew(() =>
     {
         uint eid;
         if (udpshared.entities.TryGetValue(result.endPoint, out eid))
         {
             Entity e;
             if (udpshared.world.TryGetEntity(eid, out e))
             {
                 udpshared.world.DestroyEntity(e);
                 udpshared.entities.Remove(result.endPoint);
             }
             udpshared.SendHead(result.endPoint, ConDefine.onDisconect);
         }
     }));
 }