Ejemplo n.º 1
0
        /// <summary>
        /// Returns the ping with server time stamp, passes in elapsed time of previous ping.
        /// </summary>
        public async Task<string> GetPing(int pingLatencyInTenthsOfSeconds)
        {
            App.MyAssert(App.pd.plToken != null && App.pd.plToken.Length == 128); // token is 128 char long SHA-512
            // string errorCode = "";
            // string errorMessage = "";
            string serverTime = ""; // Format:  2012:0209 18:02:31.000000 America/New_York

            // pingWithEchoRequest pin = new pingWithEchoRequest();
            pingEchoRequest pin = new pingEchoRequest();
            // pin.pingString = App.DeviceName;
            // pin.latency = pingLatencyInTenthsOfSeconds.ToString();
            pin.token = App.pd.plToken;
            pin.latency = pingLatencyInTenthsOfSeconds; // was v33: .ToString();
            App.MyAssert(!String.IsNullOrEmpty(App.PingString));
            pin.pingString = App.PingString; // Before June 2015 v 3.4, contents were set here.  Now in App.GetPingString().
            //pingWithEchoResponse pout = new pingWithEchoResponse();
            pingEchoResponse pout = new pingEchoResponse();

            try
            {
                SetPLEndpointAddress(App.pl); //read the configured endpoint address

                if (App.BlockWebServices)
                    throw new Exception(PHONY_COMMUNICATIONS_EXCEPTION);

                //pout = await App.pl.pingWithEchoAsync(pin);
                pout = await App.pl.pingEchoAsync(pin); //App.pl.pingWithEchoAsync(App.DeviceName, pingLatencyInTenthsOfSeconds.ToString());
                serverTime = pout.time;
            }
            catch (Exception e)
            {
                return "ERROR: " + e.Message;
            }
//            if (errorCode != "0")
//                return PackageErrorString(errorCode, errorMessage);

            return ChangeToErrorIfNull(serverTime);
        }
Ejemplo n.º 2
0
        // Sorta converted to v33, but can no longer return server time stamp... don't bother.
        /// <summary>
        /// Returns the ping with server time stamp
        /// </summary>
        public async Task<string> GetPing()
        {
            string serverTime = ""; // Format:  2012:0209 18:02:31.000000 America/New_York

            //pingRequest pin = new pingRequest();
            //pingResponse pout = new pingResponse();
            pingEchoResponse pout = new pingEchoResponse();

            try
            {
                SetPLEndpointAddress(App.pl); //read the configured endpoint address

                if(App.BlockWebServices)
                    throw new Exception(PHONY_COMMUNICATIONS_EXCEPTION);

                pout = await App.pl.pingEchoAsync(pin);//App.pl.pingAsync(); // No error messages from server.  From framework?
                serverTime = pout.time;
            }
            catch (Exception e)
            {
                return "ERROR: " + e.Message;
            }

            return ChangeToErrorIfNull(serverTime);
        }