Example #1
0
        public ISet <ServerAddress> Resolve(ServerAddress address)
        {
            string errorMessage = "A ResolverResolutionCompleted request is expected straight after a ResolverResolutionRequired reponse is sent";
            var    response     = new ProtocolResponse("ResolverResolutionRequired",
                                                       new
            {
                id      = ProtocolObjectManager.GenerateUniqueIdString(),
                address = Uri.Host + ":" + Uri.Port
            })
                                  .Encode();

            //Send the ResolverResolutionRequired response
            Control.SendResponse(response).ConfigureAwait(false);

            //Read the ResolverResolutionCompleted request, throw if another type of request has come in
            var result = Control.TryConsumeStreamObjectOfType <ResolverResolutionCompleted>().Result;

            if (result is null)
            {
                throw new NotSupportedException(errorMessage);
            }

            //Return a IServerAddressResolver instance thats Resolve method uses the addresses in the ResolverResolutionoCompleted request.
            return(new HashSet <ServerAddress>(result
                                               .data
                                               .addresses
                                               .Select(x =>
            {
                string[] split = x.Split(':');
                return ServerAddress.From(split[0], Convert.ToInt32(split[1]));
            })));
        }
Example #2
0
        public string AddTransaction(TransactionWrapper transation)
        {
            var key = ProtocolObjectManager.GenerateUniqueIdString();

            Transactions.Add(key, transation);
            return(key);
        }
Example #3
0
 public void SetObjectManager(ProtocolObjectManager objManager)
 {
     ObjManager = objManager;
 }
Example #4
0
 public ProtocolObjectFactory(ProtocolObjectManager manager)
 {
     ObjManager = manager;
 }