internal ServerManager(ConnectionInfo info, IConnectionListener listener, IServerListener asyncListener) { Stream stream = null; this.probeTimeoutMillis = info.probeTimeoutMillis; this.probeWarningMillis = info.probeWarningMillis; this.reconnectionTimeoutMillis = info.reconnectionTimeoutMillis; this.localPushServerProxy = new PushServerProxy(info); try { stream = this.localPushServerProxy.ConnectForSession(); try { listener.OnConnectionEstablished(); } catch (Exception) { } this.localPushServerProxy.StartSession(stream); try { listener.OnSessionStarted(); } catch (Exception) { } } catch (PhaseException) { } this.serverListener = asyncListener; }
private bool InitConnectionHandlers() { Lib.PrintLine("Starting connection handlers..."); bool anyActiveListeners = false; if (Lib.Serverinfo.TcpSocketEnabled) { tcpListener = ConnectionListenerFactory.CreateTcpConnectionListener(Lib.Serverinfo.TcpSocketPort); tcpListener.Start(); Lib.PrintLine("Started TcpListener on port " + Lib.Serverinfo.TcpSocketPort + "."); anyActiveListeners = true; } //if (Lib.Serverinfo.MsnSocketEnabled) //{ // msnListener = ConnectionListenerFactory.CreateMsnConnectionListener(Lib.Serverinfo.MsnSocketSignonEmail, // Lib.Serverinfo.MsnSocketPassword); // msnListener.Start(); // Lib.PrintLine("Started MsnListener with login " + Lib.Serverinfo.MsnSocketSignonEmail + "."); // anyActiveListeners = true; //} if (!anyActiveListeners) { Lib.PrintLine("Fatal Error! No active connection listeners. Please enable one in TigerMUD.xml"); } return(anyActiveListeners); }
public PlaylistListViewModel(string channelId, Func <IDataSource> getGeDataSource, IConnectionListener connectionListener, IContextMenuStrategy contextMenuStrategy, Action <bool> changeProgressIndicator = null) : base(getGeDataSource, connectionListener, null, changeProgressIndicator) { _channelId = channelId; _contextMenuStrategy = contextMenuStrategy; }
public virtual void CloseConnection() { IConnectionListener connListener; ServerManager connManager; lock (this.connMutex) { lock (this.stateMutex) { if (this.connManager == null) { return; } this.phase++; connManager = this.connManager; connListener = this.connListener; } this.connManager = null; this.connListener = null; } foreach (ITableManager manager2 in connManager.Close()) { manager2.NotifyUnsub(); } try { connListener.OnClose(); } catch (Exception) { } }
public ClusterBuilder AddListener(IListener listener) { var clusterListener = listener as IClusterListener; if (clusterListener != null) { _clusterListener = ClusterListenerPair.Create(_clusterListener, clusterListener); } var serverListener = listener as IServerListener; if (serverListener != null) { _serverListener = ServerListenerPair.Create(_serverListener, serverListener); } var connectionPoolListener = listener as IConnectionPoolListener; if (connectionPoolListener != null) { _connectionPoolListener = ConnectionPoolListenerPair.Create(_connectionPoolListener, connectionPoolListener); } var connectionListener = listener as IConnectionListener; if (connectionListener != null) { _connectionListener = ConnectionListenerPair.Create(_connectionListener, connectionListener); } return(this); }
public void AddListener(IConnectionListener listener) { if (!_listeners.Contains(listener)) { _listeners.Add(listener); } }
public MenuPageViewModel(int index, Func <IDataSource> getGetDataSource, IConnectionListener connectionListener) { _getDataSource = getGetDataSource; _connectionListener = connectionListener; _connectionListener.Subscribe(this); _categories = new ObservableCollection <GuideCategoryNodeViewModel>(); if (_getDataSource().IsAuthorized) { _recommendedSectionViewModel = new RecommendedSectionViewModel(_getDataSource, connectionListener, this); _subscriptions = new SubscriptionChannelsViewModel(_getDataSource, connectionListener); _history = new HistoryPageViewModel(_getDataSource, connectionListener); _likedViewModel = new LikedViewModel(_getDataSource, connectionListener); _uploadedPageViewModel = new UploadedPageViewModel(_getDataSource, connectionListener); _myPlaylistListViewModel = new MyPlaylistListViewModel(_getDataSource, connectionListener, new NoContextMenuStrategy(), this); } _categoryCommand = new RelayCommand <NavigationObject>(CategoryLoad); SelectedIndex = index; _isConnected = connectionListener.CheckNetworkAvailability(); //App.ViewModel.IndicatorHolder.Subscribe(() => //{ // ProgressIndicator = App.ViewModel.IndicatorHolder.ProgressIndicator; //}); }
internal override void OnOpen(TimeSpan timeout) { TimeoutHelper timeoutHelper = new TimeoutHelper(timeout); IConnectionListener connectionListener = this.connectionElement.CreateListener(base.ConnectionBufferSize, this.listenUri); this.connectionListener = new BufferedConnectionListener(connectionListener, base.MaxOutputDelay, base.ConnectionBufferSize); this.connectionDemuxer = new ConnectionDemuxer(this.connectionListener, base.MaxPendingAccepts, base.MaxPendingConnections, base.ChannelInitializationTimeout, base.IdleTimeout, base.MaxPooledConnections, new TransportSettingsCallback(this.OnGetTransportFactorySettings), new SingletonPreambleDemuxCallback(this.OnGetSingletonMessageHandler), new ServerSessionPreambleDemuxCallback(this.OnHandleServerSessionPreamble), new ErrorCallback(this.OnDemuxerError)); bool flag = false; try { this.connectionDemuxer.Open(timeoutHelper.RemainingTime()); flag = true; } finally { if (!flag) { if (this.registration != null) { this.registration.Dispose(); this.registration = null; } this.connectionDemuxer.Abort(); } } }
/// <summary> /// Initializes an <see cref="RpcServer"/> using the specified /// underlying connection listener. /// </summary> /// <param name="listener"> /// The listener for incoming connections. /// </param> /// <param name="rpcTarget"> /// The object where remote procedure calls from clients are /// executed on. Set this to null if you do not want to allow /// RPC calls from clients to the server. /// </param> public RpcServer(IConnectionListener listener, object rpcTarget) { _listener = listener ?? throw new ArgumentNullException(nameof(listener)); _rpcTarget = rpcTarget; _connectionReceivedSubscription = _listener.ConnectionReceived.Subscribe(OnConnectionReceived); Connections = _connections.ToDictionaryAccessor(info => info.Connection); }
public StreamingAudioServer(IConnectionListener <AudioMessage, MessageType> connectionListener, IThreadManager threadManager) { this.threadManager = threadManager; this.connectionListener = Guard.IsNull(() => connectionListener); connectionWorker = this.threadManager.StartNew(AcceptConnections); }
public virtual bool RemoveConnectionListener(IConnectionListener listener) { var removed = false; foreach (var connectionFactory in _targetConnectionFactories.Values) { var listenerRemoved = connectionFactory.RemoveConnectionListener(listener); if (!removed) { removed = listenerRemoved; } } if (DefaultTargetConnectionFactory != null) { var listenerRemoved = DefaultTargetConnectionFactory.RemoveConnectionListener(listener); if (!removed) { removed = listenerRemoved; } } _connectionListeners.Remove(listener); return(removed); }
public PeerManager(IConnectionListener connectionListener, IChainService chainService, ILogger logger) { _jobQueue = new BlockingCollection <PeerManagerJob>(); _bpAddresses = new List <byte[]>(); _whiteList = new List <byte[]>(); _connectionListener = connectionListener; _chainService = chainService; //_blockChain = blockChain; _logger = logger; _nodeName = NodeConfig.Instance.NodeName; if (!string.IsNullOrWhiteSpace(NetworkConfig.Instance.NetAllowed)) { if (Enum.TryParse(NetworkConfig.Instance.NetAllowed, out AllowedConnection myName)) { _allowedConnections = myName; } } if (NetworkConfig.Instance.NetWhitelist != null) { foreach (var peer in NetworkConfig.Instance.NetWhitelist) { _whiteList.Add(ByteArrayHelpers.FromHexString(peer)); } } SetBpConfig(); }
private void StartAcceptingConnectionsCore(IConnectionListener listener) { // REVIEW: Multiple accept loops in parallel? _ = AcceptConnectionsAsync(); async Task AcceptConnectionsAsync() { try { while (true) { var connection = await listener.AcceptAsync(); if (connection == null) { // We're done listening break; } var id = Interlocked.Increment(ref _lastConnectionId); var kestrelConnection = new KestrelConnection(id, _serviceContext, _connectionDelegate, connection, _serviceContext.Log); ThreadPool.UnsafeQueueUserWorkItem(kestrelConnection, preferLocal: false); } } catch (Exception ex) { // REVIEW: If the accept loop ends should this trigger a server shutdown? It will manifest as a hang Log.LogCritical(0, ex, "The connection listener failed to accept any new connections."); } finally { _acceptLoopTcs.TrySetResult(null); } } }
/// <summary> /// Starts the server. /// </summary> public virtual void Start() { _connectionListener = CreateConnectionListener(); _connectionListener.CommunicationChannelConnected += ConnectionListener_CommunicationChannelConnected; _connectionListener.ConnectionListenerCrushed += ConnectionListener_Crushed; _connectionListener.Start(); }
internal override void OnOpen() { connectionListener = new BufferedConnectionListener( new PipeConnectionListener(ListenUri, HostNameComparisonMode, ConnectionBufferSize, AllowedUsers, true, int.MaxValue), MaxOutputDelay, ConnectionBufferSize); if (DiagnosticUtility.ShouldUseActivity) { connectionListener = new TracingConnectionListener(connectionListener, this.ListenUri.ToString(), false); } connectionDemuxer = new ConnectionDemuxer(connectionListener, MaxPendingAccepts, MaxPendingConnections, ChannelInitializationTimeout, IdleTimeout, MaxPooledConnections, OnGetTransportFactorySettings, OnGetSingletonMessageHandler, OnHandleServerSessionPreamble, OnDemuxerError); bool startedDemuxing = false; try { connectionDemuxer.StartDemuxing(); startedDemuxing = true; } finally { if (!startedDemuxing) { connectionDemuxer.Dispose(); } } }
internal MyServerListener(LSClient owner, IConnectionListener initialListener, int currPhase) { this.owner = owner; this.initialListener = initialListener; this.currPhase = currPhase; this.queue.Start(); }
public SectionBaseViewModel( Func <IDataSource> getGeDataSource, IConnectionListener connectionListener, IPlaylistsSevice playlistService, Action <bool> changeProgressIndicator = null) : base(getGeDataSource, connectionListener, changeProgressIndicator) { if (getGeDataSource == null) { throw new ArgumentNullException("getGeDataSource"); } if (connectionListener == null) { throw new ArgumentNullException("connectionListener"); } _getDataSource = getGeDataSource; _connectionListener = connectionListener; _connectionListener.Subscribe(this); _playlistService = playlistService; _hasItems = true; _isLargeItems = SettingsHelper.GetIsLargeItems(); _loadMoreCommand = new Common.RelayCommand(LoadMore); _itemClickCommand = new RelayCommand <NavigationObject>(NavigateTo); _selectCommand = new Common.RelayCommand(SelectItems); _deleteCommand = new Common.RelayCommand(DeleteItems); _selectedItems = new ObservableCollection <NodeViewModelBase>(); //_isConnected = connectionListener.CheckNetworkAvailability(); Items = new ObservableCollection <NodeViewModelBase>(); IsItemClickEnabled = true; }
private void StartAcceptingConnectionsCore(IConnectionListener listener) { // REVIEW: Multiple accept loops in parallel? _ = AcceptConnectionsAsync(); async Task AcceptConnectionsAsync() { try { while (true) { var connection = await listener.AcceptAsync(); if (connection == null) { // We're done listening break; } _ = Execute(new KestrelConnection(connection, _serviceContext.Log)); } } catch (Exception ex) { // REVIEW: If the accept loop ends should this trigger a server shutdown? It will manifest as a hang Log.LogCritical(0, ex, "The connection listener failed to accept any new connections."); } finally { _acceptLoopTcs.TrySetResult(null); } } }
public override async IAsyncEnumerable <IConnectionListener> BindAsync([EnumeratorCancellation] CancellationToken token = default) { IConnectionListener ipv6Listener = null; IConnectionListener ipv4Listener = null; var exceptions = new List <Exception>(); try { ipv6Listener = await _listenerFactory.BindAsync(new IPEndPoint(IPAddress.IPv6Loopback, _port), token); } catch (Exception ex) when(!(ex is IOException)) { exceptions.Add(ex); } if (ipv6Listener != null) { yield return(ipv6Listener); } try { ipv4Listener = await _listenerFactory.BindAsync(new IPEndPoint(IPAddress.Loopback, _port), token); } catch (Exception ex) when(!(ex is IOException)) { exceptions.Add(ex); } if (exceptions.Count == 2) { throw new IOException($"Failed to bind to {this}", new AggregateException(exceptions)); } if (ipv4Listener != null) { yield return(ipv4Listener); } }
TransportListener(IPEndPoint endPoint) { if (TD.TcpTransportListenerListeningStartIsEnabled()) { TD.TcpTransportListenerListeningStart(this.EventTraceActivity, GetRemoteEndpointAddressPort(endPoint)); } transportType = TransportType.Tcp; SocketSettings socketSettings = new SocketSettings(); IConnectionListener connectionListener = null; if (endPoint.Address.Equals(IPAddress.Broadcast)) { if (Socket.OSSupportsIPv4) { connectionListener = new SocketConnectionListener(new IPEndPoint(IPAddress.Any, endPoint.Port), socketSettings, true); demuxer = Go(connectionListener); } if (Socket.OSSupportsIPv6) { connectionListener = new SocketConnectionListener(new IPEndPoint(IPAddress.IPv6Any, endPoint.Port), socketSettings, true); demuxerV6 = Go(connectionListener); } } else { connectionListener = new SocketConnectionListener(endPoint, socketSettings, true); demuxer = Go(connectionListener); } if (TD.TcpTransportListenerListeningStopIsEnabled()) { TD.TcpTransportListenerListeningStop(this.EventTraceActivity); } }
public void RemoveListener(IConnectionListener listener) { if (_listeners.Contains(listener)) { _listeners.Remove(listener); } }
private void StartAcceptLoop <T>(IConnectionListener <T> connectionListener, Func <T, Task> connectionDelegate, EndpointConfig?endpointConfig) where T : BaseConnectionContext { var transportConnectionManager = new TransportConnectionManager(_serviceContext.ConnectionManager); var connectionDispatcher = new ConnectionDispatcher <T>(_serviceContext, connectionDelegate, transportConnectionManager); var acceptLoopTask = connectionDispatcher.StartAcceptingConnections(connectionListener); _transports.Add(new ActiveTransport(connectionListener, acceptLoopTask, transportConnectionManager, endpointConfig)); }
public WebSocketConnection(String uri, IConnectionListener listener) { this.uri = new Uri(uri); this.listener = listener; this.props = new Hashtable(); props.Add(ProtocolConstants.QOS_FIELD, "true"); }
public virtual void AddConnectionListener(IConnectionListener connectionListener) { _connectionListener.AddListener(connectionListener); if (PublisherConnectionFactory != null) { PublisherConnectionFactory.AddConnectionListener(connectionListener); } }
public void Listen(IConnectionListener listener) { _listener = listener; _listeningThread?.Abort(); _listeningThread = new Thread(ReceiveTask); _listeningThread.Start(); }
/// <summary>Add a connection listener.</summary> /// <param name="listener">The listener.</param> public override void AddConnectionListener(IConnectionListener listener) { base.AddConnectionListener(listener); if (this.connection != null) { listener.OnCreate(this.connection); } }
public PlaylistVideoPageViewModel(string playlistId, Func <IDataSource> getDataSource, IConnectionListener connectionListener) { _connectionListener = connectionListener; _getDataSource = getDataSource; _videoViewModel = new VideoPageViewModel(); _playlistVideosViewModel = new PlaylistVideosViewModel(playlistId, getDataSource, connectionListener, PlaylistVideoItemClick); LoadPlaylistVideos(playlistId); }
public Server(IConnectionListener listener, ISerializer serializer) { Listener = listener ?? throw new ArgumentNullException(nameof(listener)); Serializer = serializer ?? throw new ArgumentNullException(nameof(serializer)); ConnectionProvider = new ConnectionProvider(); Listener.ConnectionCreated += Listener_ConnectionCreated; }
public SearchPageViewModel(Func <IDataSource> getDataSource, IConnectionListener connectionListener) : base(getDataSource, connectionListener, null) { _searchVideoViewModel = new SearchVideoViewModel(getDataSource, connectionListener, ChangeProgressIndicator, this); _searchChannelsViewModel = new SearchChannelsViewModel(getDataSource, connectionListener, ChangeProgressIndicator); _searchPlaylistsViewModel = new SearchPlaylistsViewModel(getDataSource, connectionListener, ChangeProgressIndicator); _searchSettingCommand = new RelayCommand(SearchSettings); CreateFilters(); }
public override void AddConnectionListener(IConnectionListener listener) { base.AddConnectionListener(listener); // If the connection is already alive we assume that the new listener wants to be notified if (Connection != null) { listener.OnCreate(Connection); } }
public ConnectionDemuxer(IConnectionListener listener, int maxAccepts, int maxPendingConnections, TimeSpan channelInitializationTimeout, TimeSpan idleTimeout, int maxPooledConnections, TransportSettingsCallback transportSettingsCallback, SingletonPreambleDemuxCallback singletonPreambleCallback, ServerSessionPreambleDemuxCallback serverSessionPreambleCallback, System.ServiceModel.Channels.ErrorCallback errorCallback) { this.acceptor = new ConnectionAcceptor(listener, maxAccepts, maxPendingConnections, new ConnectionAvailableCallback(this.OnConnectionAvailable), errorCallback); this.channelInitializationTimeout = channelInitializationTimeout; this.idleTimeout = idleTimeout; this.maxPooledConnections = maxPooledConnections; this.onConnectionClosed = new ConnectionClosedCallback(this.OnConnectionClosed); this.transportSettingsCallback = transportSettingsCallback; this.singletonPreambleCallback = singletonPreambleCallback; this.serverSessionPreambleCallback = serverSessionPreambleCallback; }
public void AddListener(IConnectionListener channelListener) { lock (_lock) { var listeners = new List <IConnectionListener>(_connectionListeners) { channelListener }; _connectionListeners = listeners; } }
public ListenerConnectionDemuxer(IConnectionListener listener, TransportType transportType, int maxAccepts, int initialMaxPendingConnections, TimeSpan channelInitializationTimeout, ConnectionHandleDuplicated connectionHandleDuplicated) { this.transportType = transportType; this.connectionReaders = new List<InitialServerConnectionReader>(); this.connectionHandleDuplicated = connectionHandleDuplicated; this.acceptor = new ConnectionAcceptor(listener, maxAccepts, initialMaxPendingConnections, OnConnectionAvailable); this.channelInitializationTimeout = channelInitializationTimeout; this.onConnectionClosed = new ConnectionClosedCallback(OnConnectionClosed); this.onViaDecoded = new ViaDecodedCallback(OnViaDecoded); }
public ConnectionAsync(IConnectionListener listener, String clientName, String clientVersion, ILogger logger) { _logger = logger; _connected = false; _lock = new object(); _listener = listener; _clientName = clientName; _clientVersion = clientVersion; _buffer = new ByteList(); _receivedMessagesQueue = new SizeQueue<Message>(int.MaxValue); _messagesForSendQueue = new SizeQueue<Message>(int.MaxValue); _responseHandlers = new Dictionary<int, IResponseHandler>(); }
public virtual void CloseConnection() { IConnectionListener closedListener = null; ServerManager connManager = null; MyServerListener asyncListener = null; LSClient subClient = null; lock (this.connMutex) { lock (this.stateMutex) { if (this.subClient != null) { subClient = this.subClient; this.subClient = null; } else if (this.connManager != null) { this.phase++; connManager = this.connManager; closedListener = this.connListener; asyncListener = this.asyncListener; this.connManager = null; this.connListener = null; this.asyncListener = null; } else { return; } } } if (subClient != null) { subClient.CloseConnection(); } else { foreach (ITableManager manager2 in connManager.Close()) { manager2.NotifyUnsub(); } asyncListener.OnClosed(closedListener); } }
public virtual void OnClosed(IConnectionListener closedListener) { NotificationQueue.Notify fun = null; lock (this) { this.failed = true; if (closedListener != null) { if (fun == null) { fun = delegate { closedListener.OnClose(); }; } this.queue.Add(fun); } this.queue.End(); } }
public ConnectionAcceptor(IConnectionListener listener, int maxAccepts, int maxPendingConnections, ConnectionAvailableCallback callback, ErrorCallback errorCallback) { if (maxAccepts <= 0) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("maxAccepts", maxAccepts, SR.GetString(SR.ValueMustBePositive))); } Fx.Assert(maxPendingConnections > 0, "maxPendingConnections must be positive"); this.listener = listener; this.maxAccepts = maxAccepts; this.maxPendingConnections = maxPendingConnections; this.callback = callback; this.errorCallback = errorCallback; this.onConnectionDequeued = new Action(OnConnectionDequeued); this.acceptCompletedCallback = Fx.ThunkCallback(new AsyncCallback(AcceptCompletedCallback)); this.scheduleAcceptCallback = new Action<object>(ScheduleAcceptCallback); }
internal override void OnOpen() { this.connectionListener = new BufferedConnectionListener(new PipeConnectionListener(base.ListenUri, base.HostNameComparisonMode, base.ConnectionBufferSize, base.AllowedUsers, true, 0x7fffffff), base.MaxOutputDelay, base.ConnectionBufferSize); if (DiagnosticUtility.ShouldUseActivity) { this.connectionListener = new TracingConnectionListener(this.connectionListener, base.ListenUri.ToString(), false); } this.connectionDemuxer = new ConnectionDemuxer(this.connectionListener, base.MaxPendingAccepts, base.MaxPendingConnections, base.ChannelInitializationTimeout, base.IdleTimeout, base.MaxPooledConnections, new TransportSettingsCallback(this.OnGetTransportFactorySettings), new SingletonPreambleDemuxCallback(this.OnGetSingletonMessageHandler), new ServerSessionPreambleDemuxCallback(this.OnHandleServerSessionPreamble), new System.ServiceModel.Channels.ErrorCallback(this.OnDemuxerError)); bool flag = false; try { this.connectionDemuxer.StartDemuxing(); flag = true; } finally { if (!flag) { this.connectionDemuxer.Dispose(); } } }
public void Setup() { _listener = Substitute.For<IConnectionListener>(); _streamFactory = Substitute.For<IStreamFactory>(); _endPoint = new DnsEndPoint("localhost", 27017); var serverId = new ServerId(new ClusterId(), _endPoint); _connectionInitializer = Substitute.For<IConnectionInitializer>(); _connectionInitializer.InitializeConnectionAsync(null, null, Timeout.InfiniteTimeSpan, CancellationToken.None) .ReturnsForAnyArgs(Task.FromResult(new ConnectionDescription( new ConnectionId(serverId), new IsMasterResult(new BsonDocument()), new BuildInfoResult(new BsonDocument("version", "2.6.3"))))); _subject = new BinaryConnection( serverId: serverId, endPoint: _endPoint, settings: new ConnectionSettings(), streamFactory: _streamFactory, connectionInitializer: _connectionInitializer, listener: _listener); }
internal override void OnOpen() { SocketConnectionListener connectionListener = null; if (this.listenSocket != null) { connectionListener = new SocketConnectionListener(this.listenSocket, this, false); this.listenSocket = null; } else { int port = this.registration.ListenUri.Port; if (port == -1) { port = 0x328; } connectionListener = new SocketConnectionListener(new IPEndPoint(this.ipAddress, port), this, false); } this.connectionListener = new BufferedConnectionListener(connectionListener, base.MaxOutputDelay, base.ConnectionBufferSize); if (DiagnosticUtility.ShouldUseActivity) { this.connectionListener = new TracingConnectionListener(this.connectionListener, this.registration.ListenUri.ToString(), false); } this.connectionDemuxer = new ConnectionDemuxer(this.connectionListener, base.MaxPendingAccepts, base.MaxPendingConnections, base.ChannelInitializationTimeout, base.IdleTimeout, base.MaxPooledConnections, new TransportSettingsCallback(this.OnGetTransportFactorySettings), new SingletonPreambleDemuxCallback(this.OnGetSingletonMessageHandler), new ServerSessionPreambleDemuxCallback(this.OnHandleServerSessionPreamble), new System.ServiceModel.Channels.ErrorCallback(this.OnDemuxerError)); bool flag = false; try { this.connectionDemuxer.StartDemuxing(); flag = true; } finally { if (!flag) { this.connectionDemuxer.Dispose(); } } }
internal TracingConnectionListener(IConnectionListener listener, string traceStartInfo, bool newActivity) { this.listener = listener; if (newActivity) { this.activity = ServiceModelActivity.CreateActivity(); if (DiagnosticUtility.ShouldUseActivity) { if (FxTrace.Trace != null) { FxTrace.Trace.TraceTransfer(this.activity.Id); } ServiceModelActivity.Start(this.activity, System.ServiceModel.SR.GetString("ActivityListenAt", new object[] { traceStartInfo }), ActivityType.ListenAt); } } else { this.activity = ServiceModelActivity.CreateActivity(DiagnosticTrace.ActivityId, false); if (this.activity != null) { this.activity.Name = traceStartInfo; } } }
public AgarIoService(IConnectionListener connectionListener, IGame game) { _connectionListener = connectionListener; _game = game; }
public ConnectionAcceptor(IConnectionListener listener, int maxAccepts, int maxPendingConnections, ConnectionAvailableCallback callback) : this(listener, maxAccepts, maxPendingConnections, callback, null) { // empty }
/// <summary> /// Starts the server. /// /// </summary> public virtual void Start() { this._connectionListener = this.CreateConnectionListener(); this._connectionListener.CommunicationChannelConnected += new EventHandler<CommunicationChannelEventArgs>(this.ConnectionListener_CommunicationChannelConnected); this._connectionListener.Start(); }
public void SetConnectionListener(IConnectionListener l) { _connectionListener = l; }
public void SetListener(INetworkListener l) { _listener = l; _responceListener = l; _connectionListener = l; }
public BufferedConnectionListener(IConnectionListener connectionListener, TimeSpan flushTimeout, int writeBufferSize) { this.connectionListener = connectionListener; this.flushTimeout = flushTimeout; this.writeBufferSize = writeBufferSize; }
public void AddConnectionListener(IConnectionListener connectionListener) { _connectionListeners.Add(connectionListener); }
internal TracingConnectionListener(IConnectionListener listener, string traceStartInfo) : this(listener, traceStartInfo, true) { }
public virtual void CloseConnection() { IConnectionListener activeListener = null; ServerManager closingManager = null; MyServerListener closeListener = null; LSClient closingSubClient = null; lock (this.stateMutex) { this.phase++; if (this.subClient != null) { closingSubClient = this.subClient; this.subClient = null; } else if (this.connManager != null) { closingManager = this.connManager; activeListener = this.connListener; closeListener = this.asyncListener; this.connManager = null; this.connListener = null; this.asyncListener = null; } else { return; } } if (closingSubClient != null) { closingSubClient.CloseConnection(); } else { CloseFlushing(closingManager, closeListener, activeListener); } }
public virtual void OpenConnection(ConnectionInfo info, IConnectionListener listener) { int currPhase; object CS$2$0000; lock ((CS$2$0000 = this.stateMutex)) { this.CloseConnection(); currPhase = ++this.phase; } ConnectionInfo myInfo = (ConnectionInfo) info.Clone(); if (myInfo.EnableStreamSense && !myInfo.Polling) { LSClient testClient = new LSClient(); ExtConnectionListener myListener = new ExtConnectionListener(listener); ConnectionInfo mySubInfo = (ConnectionInfo) info.Clone(); mySubInfo.EnableStreamSense = false; new Thread(delegate { try { testClient.OpenConnection(mySubInfo, myListener); } catch (Exception) { } }) { IsBackground = true }.Start(); if (!myListener.WaitStreamingTimeoutAnswer()) { lock ((CS$2$0000 = this.stateMutex)) { if (currPhase == this.phase) { this.subClient = testClient; } else { AsynchCloseConnection(testClient); return; } } myListener.FlushAndStart(); } else { AsynchCloseConnection(testClient); lock ((CS$2$0000 = this.stateMutex)) { if (currPhase != this.phase) { return; } } LSClient pollClient = new LSClient(); myInfo.Polling = true; pollClient.OpenConnection(myInfo, listener); lock ((CS$2$0000 = this.stateMutex)) { if (currPhase == this.phase) { this.subClient = pollClient; } else { AsynchCloseConnection(pollClient); } } } } else { MyServerListener serverListener = new MyServerListener(this, listener, currPhase); bool ok = false; try { ServerManager newManager = new ServerManager(myInfo, serverListener); newManager.Connect(); ok = true; lock ((CS$2$0000 = this.stateMutex)) { if (currPhase == this.phase) { this.connListener = listener; this.asyncListener = serverListener; this.connManager = newManager; } else { CloseFlushing(newManager, serverListener, listener); return; } } newManager.Start(); } finally { if (!ok) { serverListener.OnClosed(null); } } } }
private static void CloseFlushing(ServerManager closingManager, MyServerListener closeListener, IConnectionListener activeListener) { foreach (ITableManager info in closingManager.Close()) { info.NotifyUnsub(); } closeListener.OnClosed(activeListener); }
/// <summary> /// Starts the server. /// </summary> public virtual void Start() { _connectionListener = CreateConnectionListener(); _connectionListener.CommunicationChannelConnected += ConnectionListener_CommunicationChannelConnected; _connectionListener.Start(); }
internal TracingConnectionListener(IConnectionListener listener) { this.listener = listener; this.activity = ServiceModelActivity.CreateActivity(DiagnosticTrace.ActivityId, false); }
public BinaryConnectionFactory(ConnectionSettings settings, IStreamFactory streamFactory, IConnectionListener listener) { _settings = Ensure.IsNotNull(settings, "settings"); _streamFactory = Ensure.IsNotNull(streamFactory, "streamFactory"); _listener = listener; }
internal TracingConnectionListener(IConnectionListener listener, Uri uri) : this(listener, uri.ToString()) { }