internal Peer(IConnection connection) { _connection = connection; _sendSpeedWatcher = new SpeedWatcher(); _receiveSpeedWatcher = new SpeedWatcher(); _receiveBandwidthController = new UnlimitedBandwidthController(); _sendBandwidthController = new UnlimitedBandwidthController(); _statistics = new PeerStat(); _uri = new Uri("tcp://" + EndPoint.Address + ':' + EndPoint.Port); }
public CommunicationManager() { _worker = new ClientWorker(); _peers = new ConcurrentDictionary <IPEndPoint, Peer>(); GlobalReceiveSpeedWatcher = new SpeedWatcher(); GlobalSendSpeedWatcher = new SpeedWatcher(); _worker.QueueForever(CalculateSpeed, 500.Milliseconds()); _worker.Start(); }
internal Peer(Stream stream, IConnection connection) { Connection = connection; SendSpeedWatcher = new SpeedWatcher(); ReceiveSpeedWatcher = new SpeedWatcher(); SendBandwidthController = new UnlimitedBandwidthController(); ReceiveBandwidthController = new UnlimitedBandwidthController(); Statistics = new PeerStat(); Stream = new ThrottledStream(stream, ReceiveBandwidthController, SendBandwidthController); Uri = new Uri("tcp://" + EndPoint.Address + ':' + EndPoint.Port); }
/// <summary> /// Initializes a new instance of the <see cref="CommunicationManager"/> class. /// </summary> /// <example> /// var portNumber = 9876; /// var listener = new Listener(portNumber); /// var comunicationManager = new CommunicationManager(_listener); /// comunicationManager.PeerConnected += ChatOnMemberConnected; /// comunicationManager.ConnectionClosed += ChatOnMemberDisconnected; /// comunicationManager.ConnectionFailed += ChatOnMemberConnectionFailure; /// comunicationManager.PeerDataReceived += OnPeerDataReceived; /// /// listener.Start(); /// </example> /// <param name="listener">The incomming connections <see cref="Listener"/>.</param> public CommunicationManager(TcpListener listener) { _listener = listener; _worker = new ClientWorker(); _ioActor = new ConnectionIoActor(_worker, new BufferAllocator(new byte[1 << 16])); _peers = new ConcurrentDictionary <IPEndPoint, Peer>(); _globalReceiveSpeedWatcher = new SpeedWatcher(); _globalSendSpeedWatcher = new SpeedWatcher(); _worker.QueueForever(CalculateSpeed, 500.Milliseconds()); _worker.Start(); _listener.ConnectionRequested += NewPeerConnected; }