コード例 #1
0
        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);
            }
        }
コード例 #2
0
        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);
                    }
                }
            }
        }
コード例 #3
0
 private void OnConnectionReconnected(object sender, ChannelConnectedEventArgs e)
 {
     _isConnected = true;
     _monitor.OnConnectionReconnected(e);
 }
コード例 #4
0
 private void MessageChannel_ClientConnected(object sender, ChannelConnectedEventArgs e)
 {
     AddClientToList(e.Client);
 }
コード例 #5
0
        private void EndpointOnClientConnected(ChannelConnectedEventArgs args)
        {
            var connection = m_ConnectionFactory.Create(args.ConnectionId, args.ChannelStream);

            ClientConnected.Invoke(new ConnectedEventArgs(connection));
        }
コード例 #6
0
 /// <summary>
 /// 监听服务通道连接状态,当通道重新建立连接时触发。
 /// </summary>
 /// <param name="e">通道状态参数</param>
 public virtual void OnConnectionReconnected(ChannelConnectedEventArgs e)
 {
 }
コード例 #7
0
 private void Provider_ClientConnected(object sender, ChannelConnectedEventArgs e)
 {
     // TODO security check and reject
     ClientConnected?.Invoke(this, e);
 }
コード例 #8
0
 /// <summary>
 /// Triggers a <see cref="ChannelConnected"/> event.
 /// </summary>
 /// <param name="e">Event arguments.</param>
 protected virtual void OnChannelConnected(ChannelConnectedEventArgs e)
 {
     ChannelConnected?.Invoke(this, e);
 }
コード例 #9
0
 /// <summary>
 /// 监听服务通道连接状态,当通道重新建立连接时触发。
 /// </summary>
 /// <param name="e">通道状态参数</param>
 public virtual void OnConnectionReconnected(ChannelConnectedEventArgs e)
 {
 }