private void PeerConnected(PeerConnection peer) { Log.LogInformation($"Connected to peer at {peer.Address}"); lock (peersLock) peers.Add(peer); foreach (var module in modules.Modules) { var context = new PeerContext( peer, peer.GetCustomValues(module), this, messageId => RegisterModuleForMessageId(peer, module, messageId)); module.OnPeerConnected(context); } peer.ReceiveData(); }
public void PeerDisconnected(PeerConnection peer) { mainLoop.AddTask(() => underlying.PeerDisconnected(peer)); }
public void MessageReceived(PeerConnection peer, byte[] data) { mainLoop.AddTask(() => underlying.MessageReceived(peer, data)); }
private void RegisterModuleForMessageId(PeerConnection peer, IModule module, byte messageId) { lock (peersLock) messageHandlerRegistrations[Tuple.Create(peer, messageId)] = module; }
private void SetChokedByPeer(PeerConnection peer, bool choked) { peer.IsChokedByRemotePeer = choked; }
private void UnchokePeer(PeerConnection peer) { peer.IsChokingRemotePeer = false; peer.SendMessage(new UnchokeMessage()); }
private void SetPeerInterested(PeerConnection peer, bool isInterested) { peer.IsRemotePeerInterested = isInterested; }
private void SetPeerBitfield(PeerConnection peer, Bitfield bitfield) { peer.Available = bitfield; }
private void SetBlockRequestedByPeer(PeerConnection peer, BlockRequest blockRequest) { peer.RequestedByRemotePeer.Add(blockRequest); }