public async Task <string> GetUrlHelper(MobiledgeXIntegration mxi, string proto, int port = 0) { bool registerCheck = await RegisterHelper(mxi); await Task.Delay(TimeSpan.FromMilliseconds(1000)); if (!registerCheck) { throw new RegisterClientException("RegisterClient Failed"); } bool findCloudletCheck = await FindCloudletHelper(mxi); await Task.Delay(TimeSpan.FromMilliseconds(1000)); if (!findCloudletCheck) { throw new FindCloudletException("FindCloudlet Failed"); } AppPort appPort; switch (proto) { case "udp": appPort = mxi.GetAppPort(LProto.L_PROTO_UDP, port); break; case "ws": case "wss": case "http": case "https": default: appPort = mxi.GetAppPort(LProto.L_PROTO_TCP, port); break; } if (appPort == null) { throw new AppPortException("AppPort Not Found"); } string url = mxi.GetUrl(proto, appPort); return(url); }
public void UDPTest(string orgName, string appName, string appVers, int timeOutMs) { 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", 20000)); }); Assert.True(task.Result == "pong"); }