Exemple #1
0
 /// <summary>
 /// Добавить сообщение в очередь необработанных. Сюда помещаются CGateMessage сообщения, которые пока невозможно обработать,
 /// из-за отсутствия информации, которая должна прийти в других CGateMessage сообщениях.
 /// </summary>
 /// <param name="message"></param>
 private void EnqueuePendingMessage(CGateMessage message)
 {
     using (pendingIsinResolutionMessagesLock.WriteLock())
     {
         pendingIsinResolutionMessages.Enqueue(message);
     }
 }
Exemple #2
0
        public void Publish(CGateMessage message)
        {
            if (!_configuredWell)
            {
                return;
            }

            using (var messageToPost = _publisher.NewMessage(MessageKeyType.KeyName, message.MessageTypeName))
            {
                var dataMessage = (DataMessage)messageToPost;

                message.CopyToDataMessage(dataMessage);

                var extIdObj = dataMessage["ext_id"];
                if (extIdObj != null)
                {
                    dataMessage.UserId = (uint)extIdObj.asInt();
                }
                else
                {
                    dataMessage.UserId = message.UserId;
                }

                _publisher.Post(messageToPost, PublishFlag.NeedReply);
                _logger.Debug($"Publish: UserId={dataMessage.UserId}; Message={message}");
            }
        }
        void ICGateStreamCallback.HandleMessage(CGateStream stream, CGateMessage message)
        {
            lock (_streamStatesLock)
            {
                _currentState         = _streamStates.All(_ => _.Value);
                _streamStates[stream] = stream.State == State.Active;
                _newState             = _streamStates.All(_ => _.Value);
            }

            if (_newState != _currentState)
            {
                UpdateConnectionState(_newState ? CGConnectionState.Connected : CGConnectionState.Disconnected);
            }

            switch (stream.StreamType)
            {
            case CGateStreamType.FutInfo:
            case CGateStreamType.OptInfo:
                PutMessageToBothEventQueues(message);
                break;

            case CGateStreamType.FortsMessages:
            case CGateStreamType.OrdLogTrades:
            case CGateStreamType.FutTrades:
            case CGateStreamType.OptTrades:
            case CGateStreamType.Pos:
            case CGateStreamType.Part:
            case CGateStreamType.Vm:
                PutMessageToTransactionalEventQueue(message);
                break;

            default:
                PutMessageToMarketdataEventQueue(message);
                break;
            }
        }
 private void PutMessageToTransactionalEventQueue(CGateMessage message)
 {
     _executionMessages.Enqueue(message);
     _newExecutionMessageEvent.Set();
 }
 private void PutMessageToMarketdataEventQueue(CGateMessage message)
 {
     _marketdataMessages.Enqueue(message);
     _newMarketdataMessageEvent.Set();
 }
 private void PutMessageToBothEventQueues(CGateMessage message)
 {
     PutMessageToMarketdataEventQueue(message);
     PutMessageToTransactionalEventQueue(message);
 }
 private void RaiseExecutionMessageReceived(CGateMessage message)
 => ExecutionMessageReceived?.Invoke(this, new CGateMessageEventArgs(message));
 private void RaiseMarketdataMessageReceived(CGateMessage message)
 => MarketdataMessageReceived?.Invoke(this, new CGateMessageEventArgs(message));
 /// <summary>
 ///     Отправить сообщение
 /// </summary>
 public void SendMessage(CGateMessage message)
 {
     _ordersPublisher.Publish(message);
 }
 public CGateMessageEventArgs(CGateMessage message)
 {
     Message = message;
 }