public Multiplexer(IChannelConnectNotifier channelFactory) { channelFactory.PipeConnected += (sender, args) => { args.Messenger.MessageReceived += (o, @event) => MessageReceived?.Invoke(o, @event); args.Messenger.ConnectionReestablished += (o, @event) => ConnectionReestablished?.Invoke(o, @event); }; }
private void EnsureConnected() { if (this.connectionState == PipeMessengerState.Disconnected && !string.IsNullOrEmpty(this.outPipeName)) { Connect(); ConnectionReestablished?.Invoke(this, EventArgs.Empty); } }
private async void OnReconnectTry(object obj) { DeviceInformation device = obj as DeviceInformation; LoggerWrapper.Instance.WriteToConsole("Try restablishing connection to " + device.Name); bool connected = false; if (device != null) { connected = await Connect(device); } if (connected) { if (_reconnectTimer != null) { _reconnectTimer.Cancel(); } ConnectionReestablished?.Invoke(); } }
public void ReestablishConnection() { ConnectionReestablished?.Invoke(this, EventArgs.Empty); }
protected virtual void OnConnectionReestablished() { ConnectionReestablished?.Invoke(this, EventArgs.Empty); }
/// <summary> /// Add connection settings for a new host. /// </summary> /// <param name="host">The host name</param> /// <param name="messengerFactory">Factory for creating a messenger which forwards messages to the host</param> public void AddConnection(string host, Func <IMessenger> messengerFactory) { var hostConnection = new HostConnection { Host = host, MessengerFactory = messengerFactory }; this.hosts[hostConnection.Host] = hostConnection; if (hostConnection.Messenger != null) { hostConnection.Messenger.MessageReceived += (sender, @event) => MessageReceived?.Invoke(this, @event); hostConnection.Messenger.ConnectionReestablished += (sender, @event) => ConnectionReestablished?.Invoke(this, @event); } }
private void TryConnect(HostConnection hostConnection) { try { hostConnection.Messenger = hostConnection.MessengerFactory(); hostConnection.Messenger.MessageReceived += (sender, @event) => MessageReceived?.Invoke(this, @event); hostConnection.Messenger.ConnectionReestablished += (sender, @event) => ConnectionReestablished?.Invoke(this, @event); } catch (Exception ex) { Log.Warning(ex.Message); } }
internal void InvokeConnectionReestablished(Client client) { ConnectionReestablished?.Invoke(client, new ConnectionReestablishedEventArgs()); }