コード例 #1
0
        private void ParseResponse(HttpListenerResponse response, Mql4PostCommand cmd)
        {
            if (this.requestSent.TryRemove(cmd.ReqId, out var originalRequest))
            {
                if (originalRequest.Command == CommandType.StepChart ||
                    originalRequest.Command == CommandType.StepBackChart ||
                    originalRequest.Command == CommandType.CurrentPrices)
                {
                    if (originalRequest.ReqTime > this.lastPriceUpdateTime)
                    {
                        this.lastPriceUpdateTime = originalRequest.ReqTime;
                        var priceData = JsonConvert.DeserializeObject <Prices>(cmd.Data);
                        this.PricesUpdated?.Invoke(this, priceData);
                    }
                }
                else if (originalRequest.Command == CommandType.ChartInfo ||
                         originalRequest.Command == CommandType.LockChart)
                {
                    var chartInfo = JsonConvert.DeserializeObject <ChartInfo>(cmd.Data);
                    this.ChartInfo?.Invoke(this, chartInfo);
                }
            }

            SendOkResponse(response);
        }
コード例 #2
0
        private void ParseRequest(HttpListenerResponse response, Mql4PostCommand cmd)
        {
            if (cmd == null)
            {
                return;
            }

            if (cmd.Type == Mql4CommandType.POLL.ToString())
            {
                this.ParsePoll(response);
            }
            else if (cmd.Type == Mql4CommandType.RESP.ToString())
            {
                this.ParseResponse(response, cmd);
            }
        }