public EncryptMessage(int connectionId, PeerEntry peer, ArraySegment <byte> payload) { ConnectionId = connectionId; SendSequence = peer.IncrementSendSequence(); ReceiveSequence = peer.ReceiveSequence; Payload = payload; }
private void PeerList_Click(object sender, RoutedEventArgs e) { // Убедимся, что пользователь щелкнул по кнопке с именем MessageButton if (((Button)e.OriginalSource).Name == "MessageButton") { // Получение пира и прокси, для отправки сообщения PeerEntry peerEntry = ((Button)e.OriginalSource).DataContext as PeerEntry; if (peerEntry != null && peerEntry.ServiceProxy != null) { try { if (message != null) { peerEntry.ServiceProxy.SendMessage(message, ConfigurationManager.AppSettings["username"]); } else { peerEntry.ServiceProxy.SendMessage("Привет!", ConfigurationManager.AppSettings["username"]); } } catch (CommunicationException) { } } } }
internal protected override void OnRemove(PeerEntry peer) { base.OnRemove(peer); if (DisposeOnDisconnectOwner && peer.ConnectionId == SelfId) { Dispose(); } }
/** * Deletes the entry related to the peer with the specified key from the table. */ public void del(string key) { PeerEntry removed = null; map.TryRemove(key, out removed); if (removed != null) { PeerRemoved?.Invoke(removed.Peer); } }
private void OnPeerResolverFound(object sender, ResolveProgressChangedEventArgs e) { var peer = e.PeerNameRecord; foreach (var ep in peer.EndPointCollection) { if (ep.AddressFamily == AddressFamily.InterNetwork) { var remoteUrl = string.Format("net.tcp://{0}:{1}/P2PService", ep.Address, ep.Port); var binding = new NetTcpBinding(); binding.Security.Mode = SecurityMode.None; try { var peerContext = AvailablePeers.FirstOrDefault(x => x.PeerEntry.Address == remoteUrl); if (peerContext == null) { IP2PService remoteService = ChannelFactory <IP2PService> .CreateChannel( binding, new EndpointAddress(remoteUrl)); var peerEntry = new PeerEntry(remoteService, remoteUrl); _foundPeers.Add(peerEntry); _logger.Debug($"New peer found: {peerEntry}"); } else { _foundPeers.Add(peerContext.PeerEntry); } } catch (Exception ex) when(ex is InvalidOperationException || ex is CommunicationException) { _logger.Error(ex, "Cannot process new peer: {0}", ex.Message); } } } }
public PeerEntryResult(PeerEntry value) : this() { Value = value; }
public PeerEntryResult(PeerEntry value) { Value = value; FailureReason = null; }
public Pong(int connectionId, PeerEntry peer) { ConnectionId = connectionId; SendSequence = peer.IncrementSendSequence(); ReceiveSequence = peer.ReceiveSequence; }
public void AddOrUpdatePeer(PeerDescriptor peerDescriptor) { var newPeerEntry = new PeerEntry(peerDescriptor); _peers.AddOrUpdate(peerDescriptor.PeerId, newPeerEntry, (peerId, existingPeerEntry) => peerDescriptor.TimestampUtc >= existingPeerEntry.PeerDescriptor.TimestampUtc ? newPeerEntry : existingPeerEntry); }