Exemple #1
0
        private Guid SubscribeCore(IEventFilter filter,
                                   DataReceiveEventHandler receiveEventHandler,
                                   out IReceiverChannel channel)
        {
            Guid cookie;

            // создаем канал ответа (интегральный)
            var localChannel = UnitySingleton.Resolve <ITransport>().CreateIntegralChannel();

            channel = (IReceiverChannel)localChannel;

            // создаем кук
            cookie = Guid.NewGuid();

            // подписываемся на событие прихода данных по каналу
            if (receiveEventHandler != null)
            {
                channel.DataReceived += receiveEventHandler;
            }

            // посылаем команду в Blackboard
            _localBlackboard.Subscribe(filter, localChannel as ISenderChannel, cookie);

            return(cookie);
        }
Exemple #2
0
 private static void ReceiverChannelStatusChanged(object sender, EventArgs e)
 {
     recChanel = (IReceiverChannel)sender;
     Task.Run(async() =>
     {
         recStatus = await recChanel.GetStatusAsync();
     });
 }
Exemple #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ReceiverEndPoint"/> class.
        /// </summary>
        /// <param name="uri">The URI.</param>
        /// <param name="channelController">The channel controller.</param>
        /// <param name="receiverChannel">The channel.</param>
        public ReceiverEndPoint(Uri uri, IChannelController channelController, IReceiverChannel receiverChannel)
        {
            Uri = uri;
            _channelController = channelController;
            _receiverChannel = receiverChannel;

            _receiverChannel = receiverChannel;
            _receiverChannel.OnReceivedMessage += OnReceiverChannelMessageReceived;
            _receiverChannel.OnStop += OnReceiverChannelStoped;
            _receiverChannel.OnStart += OnReceiverChannelStarted;
        }
Exemple #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ReceiverEndPoint"/> class.
        /// </summary>
        /// <param name="uri">The URI.</param>
        /// <param name="channelController">The channel controller.</param>
        /// <param name="receiverChannel">The channel.</param>
        public ReceiverEndPoint(Uri uri, IChannelController channelController, IReceiverChannel receiverChannel)
        {
            Uri = uri;
            _channelController = channelController;
            _receiverChannel   = receiverChannel;

            _receiverChannel = receiverChannel;
            _receiverChannel.OnReceivedMessage += OnReceiverChannelMessageReceived;
            _receiverChannel.OnStop            += OnReceiverChannelStoped;
            _receiverChannel.OnStart           += OnReceiverChannelStarted;
        }
Exemple #5
0
        public Player(
            ILogger logger,
            IReceiver receiver,
            string destinationId = AppConstants.DESTINATION_ID,
            string senderId      = AppConstants.SENDER_ID,
            bool logToConsole    = true,
            bool logTrace        = false)
        {
            _logger         = logger;
            _destinationId  = destinationId;
            CanLogToConsole = logToConsole;
            CanLogTrace     = logTrace;

            _sender = new Sender(_logger, senderId, receiver, HandleResponseMsg);
            _sender.Disconnected += OnDisconnect;
            _connectionChannel    = new ConnectionChannel(destinationId);
            _heartbeatChannel     = new HeartbeatChannel(destinationId);
            _mediaChannel         = new MediaChannel(destinationId, async() =>
            {
                var app = await _receiverChannel.GetApplication(_sender, _connectionChannel, _mediaChannel.Namespace);
                return(app.SessionId);
            });
            _receiverChannel = new ReceiverChannel(destinationId);
        }
Exemple #6
0
        void OnReceiveEvent1(IReceiverChannel channel)
        {
            try
            {
                object obj;
                channel.GetData(out obj);

                var ev = (Event)obj;

                if (ev.ExtData is EventData eventData)
                {
                    Console.WriteLine($"Пришло сообщение из журнала: {eventData.EventName} {eventData.EventCount} {eventData.EventDate}");
                }
                else
                {
                    Debug.Assert(false, "Данные должны приходить типа {EventData}");
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Ошибка при обработке данных из журнала.");
                //Log.ErrorException("Ошибка при обработке данных из журнала.", e);
            }
        }
 private void DisposeChannel(IReceiverChannel receiverChannel)
 {
     receiverChannel.Dispose();
 }
 private void DisposeChannel(IReceiverChannel receiverChannel)
 {
     receiverChannel.Dispose();
 }
Exemple #9
0
 /// <summary>
 /// Метод подписки на события журнала.
 /// </summary>
 /// <param name="filter">Фильтр событий.</param>
 /// <param name="channel">Канал передачи событий.</param>
 /// <param name="receiveEventHandler">Обработчик события получения данных в канал. Необязательный параметр.</param>
 /// <param name="cookie">Идентификатор подписки.</param>
 public void Subscribe(IEventFilter filter, out IReceiverChannel channel,
                       DataReceiveEventHandler receiveEventHandler, out Guid cookie)
 {
     cookie = SubscribeCore(filter, receiveEventHandler, out channel);
 }