public string UDPMessageHelper(MobiledgeXUDPClient mxiUDP, string message, int timeOutMs) { mxiUDP.Send(message); System.Diagnostics.Stopwatch stopWatch = new System.Diagnostics.Stopwatch(); stopWatch.Start(); while (mxiUDP.receiveQueue.Count == 0 && stopWatch.ElapsedMilliseconds < timeOutMs) { //Debug.Log("Waiting for UDP Received messgae"); } stopWatch = null; byte[] receivedBytes; mxiUDP.receiveQueue.TryDequeue(out receivedBytes); return(Encoding.ASCII.GetString(receivedBytes)); }
public void UDPTest(string orgName, string appName, string appVers, int timeOutMs) { using (MobiledgeXIntegration mxi = new MobiledgeXIntegration(new CarrierInfoClass(), null, new UniqueIDClass(), new TestDeviceInfo())) { mxi.appName = appName; mxi.appVers = appVers; mxi.orgName = orgName; var task = Task.Run(async() => { string hostName = await GetHostHelper(mxi, "udp"); MobiledgeXUDPClient udpClient = new MobiledgeXUDPClient(hostName, mxi.GetAppPort(LProto.L_PROTO_UDP).public_port); return(UDPMessageHelper(udpClient, "ping", timeOutMs)); }); Assert.True(task.Result == "pong"); } }