示例#1
0
        /// <summary>
        /// Process the completed call sample.
        /// </summary>
        /// <param name="reply">Call reply arguments.</param>
        void ProcessReturnedCall(CallReply reply)
        {
            DateTime callEnd = DateTime.Now;

            numCalls++;

            // Only collect samples that are not in the heat-up process.
            if (numCalls > heatUpCalls)
            {
                accumulatedLatencyMs += (callEnd - callStart);
            }

            if (numCalls < totalCalls)
            {
                // Start next call.
                callStart = DateTime.Now;
                int callID = communicator.Call("getTime");
                communicator.AddReplyHandler(callID, ProcessReturnedCall);
            }
            else if (TimeDelayEstimated != null)
            {
                // Estimate latency and compute time delay.
                double   latency        = accumulatedLatencyMs.TotalMilliseconds / totalCalls;
                DateTime remoteTime     = reply.RetValue.ToObject <DateTime>();
                TimeSpan timeDifference = remoteTime - callStart;
                double   timeDelay      = timeDifference.TotalMilliseconds - latency / 2;
                TimeDelayEstimated(this, new TimeDelayEventArgs(timeDelay));
            }
        }
        /// <summary>
        /// Process the completed call sample.
        /// </summary>
        /// <param name="reply">Call reply arguments.</param>
        void ProcessReturnedCall(CallReply reply)
        {
            DateTime callEnd = DateTime.Now;

            numCalls++;

            // Only collect samples that are not in the heat-up process.
            if (numCalls > heatUpCalls)
                accumulatedLatencyMs += (callEnd - callStart);

            if (numCalls < totalCalls)
            {
                // Start next call.
                callStart = DateTime.Now;
                int callID = communicator.Call("getTime");
                communicator.AddReplyHandler(callID, ProcessReturnedCall);
            }
            else if (TimeDelayEstimated != null)
            {
                // Estimate latency and compute time delay.
                double latency = accumulatedLatencyMs.TotalMilliseconds / totalCalls;
                DateTime remoteTime = (DateTime)reply.RetValue;
                TimeSpan timeDifference = remoteTime - callStart;
                double timeDelay = timeDifference.TotalMilliseconds - latency / 2;
                TimeDelayEstimated(this, new TimeDelayEventArgs(timeDelay));
            }
        }
        void HandleQueryAuthInterfaceReply(CallReply reply)
        {
            if (!reply.Success)
				Console.WriteLine("Failed to request auth service: {0}", reply.Message);

            List<object> retValue = (List<object>)reply.RetValue;
            if (!(bool) retValue[0])
				Console.WriteLine("No auth service.");

            int callID = Communicator.Call("auth.login", GenerateRandomLogin(), "");
            Communicator.AddReplyHandler(callID, HandleAuthorizationReply);
        }
        void HandleAuthorizationReply(CallReply reply)
        {
            if (!reply.Success)
				Console.WriteLine("Failed on authentication: {0}", reply.Message);

            bool success = (bool)reply.RetValue;
            if (!success)
                Console.WriteLine("Incorrect login/password", reply.Message);

            if (Authenticated != null)
                Authenticated(this, new EventArgs());
        }
示例#5
0
        void HandleQueryAuthInterfaceReply(CallReply reply)
        {
            if (!reply.Success)
                Logger.Fatal("Failed to request auth service: {0}", reply.Message);

            List<bool> retValue = reply.RetValue.ToObject<List<bool>>();
            if (!retValue[0])
                Logger.Fatal("No auth service.");

            int callID = Communicator.Call("auth.login", GenerateRandomLogin(), "");
            Communicator.AddReplyHandler(callID, HandleAuthorizationReply);
        }
示例#6
0
        void HandleAuthorizationReply(CallReply reply)
        {
            if (!reply.Success)
                Logger.Fatal("Failed on authentication: {0}", reply.Message);

            bool success = reply.RetValue.ToObject<bool>();
            if (!success)
                Logger.Fatal("Incorrect login/password", reply.Message);

            if (Authenticated != null)
                Authenticated(this, new EventArgs());
        }
        void HandleAuthorizationReply(CallReply reply)
        {
            if (!reply.Success)
                Logger.Fatal("Failed on authentication: {0}", reply.Message);

            bool success = reply.RetValue.ToObject<bool>();
            if (!success)
                Logger.Fatal("Incorrect login/password", reply.Message);

            if (Authenticated != null)
                Authenticated(this, new EventArgs());
        }
示例#8
0
        private void HandleRequestAllObjectReply(CallReply reply)
        {
            if (!reply.Success)
            {
                logger.Fatal("Failed to list objects: {0}", reply.Message);
            }

            List <JToken> retValue = reply.RetValue.ToObject <List <JToken> >();

            retValue.ForEach(HandleNewObject);

            if (Loaded != null)
            {
                Loaded(this, new EventArgs());
            }
        }
        private void HandleRequestAllObjectReply(CallReply reply)
        {
            if (!reply.Success)
            {
                Console.WriteLine("Failed to list objects: {0}", reply.Message);
            }

            List <Dictionary <string, object> > retValue = reply.RetValue as List <Dictionary <string, object> >;

            retValue.ForEach(HandleNewObject);

            if (Loaded != null)
            {
                Loaded(this, new EventArgs());
            }
        }
        private void HandleQueryClientServicesReply(CallReply reply)
        {
            if (!reply.Success)
            {
                Console.WriteLine("Failed to request client services: {0}", reply.Message);
            }

            List <bool> retValue = reply.RetValue as List <bool>;

            if (!retValue.TrueForAll(s => s))
            {
                Console.WriteLine("Required client services are not supported");
            }

            RegisterHandlers();
            RequestAllObjects();
        }
        void HandleQueryAuthInterfaceReply(CallReply reply)
        {
            if (!reply.Success)
            {
                Console.WriteLine("Failed to request auth service: {0}", reply.Message);
            }

            List <object> retValue = (List <object>)reply.RetValue;

            if (!(bool)retValue[0])
            {
                Console.WriteLine("No auth service.");
            }

            int callID = Communicator.Call("auth.login", GenerateRandomLogin(), "");

            Communicator.AddReplyHandler(callID, HandleAuthorizationReply);
        }
示例#12
0
        private void HandleQueryClientServicesReply(CallReply reply)
        {
            if (!reply.Success)
            {
                logger.Fatal("Failed to request client services: {0}", reply.Message);
            }

            List <bool> retValue = reply.RetValue.ToObject <List <bool> >();

            if (!retValue.TrueForAll(s => s))
            {
                logger.Fatal("Required client services are not supported: {0}",
                             String.Join(", ", retValue.FindAll(s => !s)));
            }

            RegisterHandlers();
            RequestAllObjects();
        }
        void HandleAuthorizationReply(CallReply reply)
        {
            if (!reply.Success)
            {
                Console.WriteLine("Failed on authentication: {0}", reply.Message);
            }

            bool success = (bool)reply.RetValue;

            if (!success)
            {
                Console.WriteLine("Incorrect login/password", reply.Message);
            }

            if (Authenticated != null)
            {
                Authenticated(this, new EventArgs());
            }
        }
        private void HandleQueryClientServicesReply(CallReply reply)
        {
            if (!reply.Success)
                logger.Fatal("Failed to request client services: {0}", reply.Message);

            List<bool> retValue = reply.RetValue.ToObject<List<bool>>();
            if (!retValue.TrueForAll(s => s)) {
                logger.Fatal("Required client services are not supported: {0}",
                             String.Join(", ", retValue.FindAll(s => !s)));
            }

            RegisterHandlers();
            RequestAllObjects();
        }
        void HandleQueryAuthInterfaceReply(CallReply reply)
        {
            if (!reply.Success)
                Logger.Fatal("Failed to request auth service: {0}", reply.Message);

            List<bool> retValue = reply.RetValue.ToObject<List<bool>>();
            if (!retValue[0])
                Logger.Fatal("No auth service.");

            int callID = Communicator.Call("auth.login", GenerateRandomLogin(), "");
            Communicator.AddReplyHandler(callID, HandleAuthorizationReply);
        }
		private void HandleRequestAllObjectReply (CallReply reply)
		{
			if (!reply.Success)
				Console.WriteLine ("Failed to list objects: {0}", reply.Message);

			List<Dictionary<string, object>> retValue = reply.RetValue as List<Dictionary<string, object>>;
			retValue.ForEach (HandleNewObject);

			if (Loaded != null)
				Loaded (this, new EventArgs ());
		}
		private void HandleQueryClientServicesReply (CallReply reply)
		{
			if (!reply.Success)
				Console.WriteLine ("Failed to request client services: {0}", reply.Message);

			List<bool> retValue = reply.RetValue as List<bool>;
			if (!retValue.TrueForAll (s => s)) {
				Console.WriteLine ("Required client services are not supported");
			}

			RegisterHandlers ();
			RequestAllObjects ();
		}
        private void HandleRequestAllObjectReply(CallReply reply)
        {
            if (!reply.Success)
                logger.Fatal("Failed to list objects: {0}", reply.Message);

            List<JToken> retValue = reply.RetValue.ToObject<List<JToken>>();
            retValue.ForEach(HandleNewObject);

            if (Loaded != null)
                Loaded(this, new EventArgs());
        }