// -- Listening Functionality // Handle listening protected override void ListenCallback() { base.ListenCallback(); while (IsListening) { try { //IP Of sender... could be anyone IPEndPoint anyIP = new IPEndPoint(IPAddress.Parse(UPP_Utils.GetLocalIPAddress()), 0); byte[] data = receiveSocket.Receive(ref anyIP); // Connect to latest packet? //if(anyIP != ) //Debug.Log("Rece sock: rece data: " + Encoding.UTF8.GetString(data)); OnReceivePacket(data, anyIP); //Thread.Sleep(1); } catch (Exception err) { Debug.Log(err.ToString()); } } }
protected override void OpenReceiveSocket(string a_remoteAddress, int a_listenPort) { receiveSocket = new TcpListener(IPAddress.Parse(UPP_Utils.GetLocalIPAddress()), a_listenPort); receiveSocket.Start(); Debug.Log("Receiving Socket: " + ((IPEndPoint)receiveSocket.LocalEndpoint).Address + ":" + ((IPEndPoint)receiveSocket.LocalEndpoint).Port); base.OpenReceiveSocket(a_remoteAddress, a_listenPort); }
public override void ParseData(string a_data) { base.ParseData(a_data); string[] splitComps = a_data.Split(':'); transform.position = UPP_Utils.StringToVector3(splitComps[0]); transform.rotation = Quaternion.Euler(UPP_Utils.StringToVector3(splitComps[1])); }
// -- Overriden internal functionality public override string StringifyData() { base.StringifyData(); return(UPP_Utils.Vector3ToString(transform.position) + ":" + UPP_Utils.Vector3ToString(transform.rotation.eulerAngles)); }