private void ReceiveDataAsync(IAsyncResult msgResult) { IPEndPoint anyIP = new IPEndPoint(IPAddress.Parse("127.0.0.1"),port); byte [] msg = client.EndReceive (msgResult,ref anyIP); String text = Encoding.UTF8.GetString (msg); String[] coordonees = text.Split(':'); tmp = new Vector3(float.Parse(coordonees[2]),float.Parse(coordonees[1]),float.Parse(coordonees[0])); ReceiveOperationInfo msgInfo = new ReceiveOperationInfo (); msgInfo.msgUDPClient = client; msgInfo.msgIPEndPoint = new IPEndPoint(IPAddress.Parse("127.0.0.1"),port); client.BeginReceive (new AsyncCallback (ReceiveDataAsync), msgInfo); }
void Start() { X = new Queue<float> (); Y = new Queue<float> (); Z = new Queue<float> (); client = new UdpClient (port); ReceiveOperationInfo msgInfo = new ReceiveOperationInfo (); msgInfo.msgUDPClient = client; msgInfo.msgIPEndPoint = new IPEndPoint(IPAddress.Parse("127.0.0.1"),port); client.BeginReceive (new AsyncCallback (ReceiveDataAsync), msgInfo); }