internal void CollectAndBroadcastMeasures()
        {
            var sample = this.MainServer.MeasurementMgr.Collect();

            Contracts.JsonResponse response = new Contracts.JsonResponse();
            response.IsSynchronous = false;
            response.Data          = sample;

            this.PushToQueue("statsQueue", response);
        }
        // dispatch Method
        public override void Dispatch(int methodId, object _request, Connection user)
        {
            if (methodId == 1)
            {
                //
                GetServerInfoRequest request = (GetServerInfoRequest)_request;

                JsonResponse response = new JsonResponse();
                response.IsSynchronous        = true;
                response.OriginatingRequestId = request.RequestId;


                // Now invoke:
                try{
                    response.Data = this.GetServerInfo(user);
                }// try
                catch (System.Exception ex)
                {
                    response.IsCallSucceeded = false;
                    response.Exception       = ex.Message;
                    user.SendMessage(response);
                    return;
                }

                response.IsCallSucceeded = true;
                user.SendMessage(response);
            }

            if (methodId == 2)
            {
                //
                StartProfilingRequest request = (StartProfilingRequest)_request;

                JsonResponse response = new JsonResponse();
                response.IsSynchronous        = true;
                response.OriginatingRequestId = request.RequestId;


                // Now invoke:
                try{
                    response.Data = null;
                    this.StartProfiling(user);
                }// try
                catch (System.Exception ex)
                {
                    response.IsCallSucceeded = false;
                    response.Exception       = ex.Message;
                    user.SendMessage(response);
                    return;
                }

                response.IsCallSucceeded = true;
                user.SendMessage(response);
            }

            if (methodId == 3)
            {
                //
                StopProfilingRequest request = (StopProfilingRequest)_request;

                JsonResponse response = new JsonResponse();
                response.IsSynchronous        = true;
                response.OriginatingRequestId = request.RequestId;


                // Now invoke:
                try{
                    response.Data = null;
                    this.StopProfiling(user);
                }// try
                catch (System.Exception ex)
                {
                    response.IsCallSucceeded = false;
                    response.Exception       = ex.Message;
                    user.SendMessage(response);
                    return;
                }

                response.IsCallSucceeded = true;
                user.SendMessage(response);
            }

            if (methodId == 4)
            {
                //
                SubscribeToFeedsRequest request = (SubscribeToFeedsRequest)_request;

                JsonResponse response = new JsonResponse();
                response.IsSynchronous        = true;
                response.OriginatingRequestId = request.RequestId;


                // Now invoke:
                try{
                    response.Data = null;
                    this.SubscribeToFeeds(user);
                }// try
                catch (System.Exception ex)
                {
                    response.IsCallSucceeded = false;
                    response.Exception       = ex.Message;
                    user.SendMessage(response);
                    return;
                }

                response.IsCallSucceeded = true;
                user.SendMessage(response);
            }

            if (methodId == 5)
            {
                //
                UnsubscribeFromFeedsRequest request = (UnsubscribeFromFeedsRequest)_request;

                JsonResponse response = new JsonResponse();
                response.IsSynchronous        = true;
                response.OriginatingRequestId = request.RequestId;


                // Now invoke:
                try{
                    response.Data = null;
                    this.UnsubscribeFromFeeds(user);
                }// try
                catch (System.Exception ex)
                {
                    response.IsCallSucceeded = false;
                    response.Exception       = ex.Message;
                    user.SendMessage(response);
                    return;
                }

                response.IsCallSucceeded = true;
                user.SendMessage(response);
            }
        }