private void RequestPeerHash() { if (Status == PeerStatus.NoHashRecieved) { var message = new PeerHashMessage(VotingsUser.PublicKey, true); if (ConnectionMode == ConnectionMode.Direct) { //проверка на дисконнект try { Connection.SendObject(message.GetType().Name, message); } catch { Status = PeerStatus.Disconnected; Connect(); } } else { tracker.SendMessageToPeer(message, this); } } else if (Status == PeerStatus.Disconnected) { Connect(); } }
private void OnPeerHashMessageFromTracker(PacketHeader packetHeader, Connection connection, PeerHashMessage incomingObject) { var messageToSend = new PeerHashMessage(VotingsUser.PublicKey, false); try { Connection.SendObject(messageToSend.GetType().Name, messageToSend); } catch { Status = TrackerStatus.Disconnected; Connect(); } }
private void OnPeerHashMessageDirect(PeerHashMessage message) { if (message.PeerHash != string.Empty && message.PeerHash != null) { Hash = message.PeerHash; Status = PeerStatus.Connected; CommonHelpers.LogPeers(allPeers); //возможно стоит отключить повторную отправку сообщения, чтобы они не дублировались if (message.NeedResponse == true) { var messageToSend = new PeerHashMessage(VotingsUser.PublicKey, false); Connection.SendObject(messageToSend.GetType().Name, messageToSend); } } }