public Task <Message> GetLatestAsync(PeerAddress remotePeer, GetBuilder getBuilder, ChannelCreator channelCreator, Rpc.Commands command) { var message = CreateRequestMessage(remotePeer, command.GetNr(), Message.MessageType.Request1); if (getBuilder.IsSign) { message.SetPublicKeyAndSign(getBuilder.KeyPair); } message.SetKey(getBuilder.LocationKey); message.SetKey(getBuilder.DomainKey); message.SetKey(getBuilder.ContentKey); var tcsResponse = new TaskCompletionSource <Message>(message); var requestHandler = new RequestHandler(tcsResponse, PeerBean, ConnectionBean, getBuilder); if (!getBuilder.IsForceUdp) { return(requestHandler.SendTcpAsync(channelCreator)); } return(requestHandler.SendUdpAsync(channelCreator)); }
public Task <Message> GetAsync(PeerAddress remotePeer, GetBuilder getBuilder, ChannelCreator channelCreator) { Message.MessageType type; if (getBuilder.IsAscending && getBuilder.IsBloomFilterAnd) { type = Message.MessageType.Request1; } else if (!getBuilder.IsAscending && getBuilder.IsBloomFilterAnd) { type = Message.MessageType.Request2; } else if (getBuilder.IsAscending && !getBuilder.IsBloomFilterAnd) { type = Message.MessageType.Request3; } else { type = Message.MessageType.Request4; } var message = CreateRequestMessage(remotePeer, Rpc.Commands.Get.GetNr(), type); if (getBuilder.IsSign) { message.SetPublicKeyAndSign(getBuilder.KeyPair); } if (getBuilder.IsRange) { var keys = new List <Number640>(2); keys.Add(getBuilder.From); keys.Add(getBuilder.To); message.SetIntValue(getBuilder.ReturnNr); message.SetKeyCollection(new KeyCollection(keys)); } else if (getBuilder.Keys == null) { if (getBuilder.LocationKey == null || getBuilder.DomainKey == null) { throw new ArgumentException("Null not allowed in location or domain."); } message.SetKey(getBuilder.LocationKey); message.SetKey(getBuilder.DomainKey); if (getBuilder.ContentKeys != null) { message.SetKeyCollection(new KeyCollection(getBuilder.LocationKey, getBuilder.DomainKey, getBuilder.VersionKey, getBuilder.ContentKeys)); } else { message.SetIntValue(getBuilder.ReturnNr); if (getBuilder.ContentKeyBloomFilter != null) { message.SetBloomFilter(getBuilder.ContentKeyBloomFilter); } else { if (getBuilder.IsBloomFilterAnd) { message.SetBloomFilter(FullFilter); } else { message.SetBloomFilter(EmptyFilter); } } if (getBuilder.VersionKeyBloomFilter != null) { message.SetBloomFilter(getBuilder.VersionKeyBloomFilter); } else { if (getBuilder.IsBloomFilterAnd) { message.SetBloomFilter(FullFilter); } else { message.SetBloomFilter(EmptyFilter); } } if (getBuilder.ContentBloomFilter != null) { message.SetBloomFilter(getBuilder.ContentBloomFilter); } else { if (getBuilder.IsBloomFilterAnd) { message.SetBloomFilter(FullFilter); } else { message.SetBloomFilter(EmptyFilter); } } } } else { message.SetKeyCollection(new KeyCollection(getBuilder.Keys)); } var tcsResponse = new TaskCompletionSource <Message>(message); var requestHandler = new RequestHandler(tcsResponse, PeerBean, ConnectionBean, getBuilder); if (!getBuilder.IsForceUdp) { return(requestHandler.SendTcpAsync(channelCreator)); } return(requestHandler.SendUdpAsync(channelCreator)); }
public TcsGet Get(GetBuilder builder) { throw new NotImplementedException(); }