private async Task NewConnectionListenerLoop() { try { while (_shouldContinueNewConnectionsTask) { // Perform a blocking call to accept requests. TcpClient tcpClient = await _tcpServer.AcceptTcpClientAsync(); if (_enabled && ChannelConnected != null) { var newChannel = new Channel(tcpClient, _newChannelOptions); var connectionReceivedEventArgs = new ChannelConnectedEventArgs(newChannel); OnChannelConnected(connectionReceivedEventArgs); } else { tcpClient.Close(); } await Task.Delay(DEFAULT_DELAY); } } catch (InvalidOperationException e) { throw new HubFailureException($"The {nameof(Hub)} found a problem and it is going to stop. Error was: {e.Message}", e); } catch (SocketException e) { throw new HubFailureException($"The {nameof(Hub)} found a network problem and it is going to stop. Error was: {e.Message}", e); } }
private void OnProxyChannelManagerChannelReconnected(object sender, ChannelConnectedEventArgs e) { List <EventHandler <ChannelConnectedEventArgs> > subscribers; if (_channelReconnectedEventSubscribers.TryGetValue(e.ContractInfo.Key, out subscribers)) { foreach (EventHandler <ChannelConnectedEventArgs> listener in subscribers) { try { if (listener != null) { listener(this, e); } } catch (Exception ex) { ExceptionHandler.Handle(ex); } } } }
private void OnConnectionReconnected(object sender, ChannelConnectedEventArgs e) { _isConnected = true; _monitor.OnConnectionReconnected(e); }
private void MessageChannel_ClientConnected(object sender, ChannelConnectedEventArgs e) { AddClientToList(e.Client); }
private void EndpointOnClientConnected(ChannelConnectedEventArgs args) { var connection = m_ConnectionFactory.Create(args.ConnectionId, args.ChannelStream); ClientConnected.Invoke(new ConnectedEventArgs(connection)); }
/// <summary> /// 监听服务通道连接状态,当通道重新建立连接时触发。 /// </summary> /// <param name="e">通道状态参数</param> public virtual void OnConnectionReconnected(ChannelConnectedEventArgs e) { }
private void Provider_ClientConnected(object sender, ChannelConnectedEventArgs e) { // TODO security check and reject ClientConnected?.Invoke(this, e); }
/// <summary> /// Triggers a <see cref="ChannelConnected"/> event. /// </summary> /// <param name="e">Event arguments.</param> protected virtual void OnChannelConnected(ChannelConnectedEventArgs e) { ChannelConnected?.Invoke(this, e); }