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); }
private static void ReceiverChannelStatusChanged(object sender, EventArgs e) { recChanel = (IReceiverChannel)sender; Task.Run(async() => { recStatus = await recChanel.GetStatusAsync(); }); }
/// <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; }
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); }
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(); }
/// <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); }