Jump to content

How to create Node in other thread?


photo

Recommended Posts

I need to receive UDP data and create nodes dynamically. 

public override bool Init()
{
  UDPClient = new UDP();
  UDPClient.OnReciveDate += InitModel;

  task = Task.Run(() =>
                  {
                    UDPClient.Recive();
                  });
  return true;
}

 private void InitModel(byte[] buf)
 {
   try
   {

     var res = Util.BytesToStruct(buf);
    
     NodeReference node = new NodeReference("capsule.Node");
     n.Name = res.Id;

   }
   catch (Exception ex)
   {
     Log.ErrorLine(ex.Message);
     Log.ErrorLine(ex.StackTrace);
   }
 }

 

Link to comment

And I try to use AsyncQueue. But I can't use it.Nodes create by AsyncQueue cant't show in the world.

Edited by wlyx123
Link to comment
×
×
  • Create New...