Inheritance: ICommunicationControllerFactory
Ejemplo n.º 1
0
 public static string ExecuteServiceOnLocalhostUsingProxy(string serviceName, Dictionary<string,string> payloadArguments)
 {
     CommunicationControllerFactory fact = new CommunicationControllerFactory();
     var comm = fact.CreateController(serviceName);
     var prx = new ServerProxy("http://localhost:3142", CredentialCache.DefaultNetworkCredentials, new TestAsyncWorker());
     prx.Connect(Guid.NewGuid());
     foreach (var payloadArgument in payloadArguments)
     {
         comm.AddPayloadArgument(payloadArgument.Key, payloadArgument.Value);
     }
     if(comm != null)
     {
         var messageToExecute = comm.ExecuteCommand<ExecuteMessage>(prx, Guid.Empty);
         if(messageToExecute != null)
         {
             var responseMessage = messageToExecute.Message;
             if(responseMessage != null)
             {
                 var actual = responseMessage.ToString();
                 return actual;
             }
             return "Error: response message empty!";
         }
         return "Error: message to send to localhost server could not be generated.";
     }
     return "Error: localhost server controller could not be created.";
 }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            string uri = "http://*****:*****@"C:\temp\networkSpeedTo{0}.csv", uri.Replace(':', '-').Replace('/', '_')); 

            // header
            timings.Add(string.Format("URI:, '{0}'", uri));
            timings.Add(string.Format("Max message size:, {0}, Initial block size:, {1}, Incrementing factor:, {2}, Rounds per packet size:, {3}", maxMessageSize, numberOfGuidsPerChunk, incrementingFactor, roundsPerPacketStep));

            using (var serverProxy = new ServerProxy(new Uri(uri)))
            {
                serverProxy.Connect(Guid.NewGuid());
                CommunicationControllerFactory cf = new CommunicationControllerFactory();
                while (sb.Length < maxMessageSize)
                {
                    timingsPerRound.Clear();
                    for (int i = 0; i < roundsPerPacketStep; i++)
                    {
                        var controller = cf.CreateController("TestNetworkService");
                        controller.AddPayloadArgument("payload", sb);
                        DateTime start = DateTime.Now;
                        // send very large message
                        var svc = controller.ExecuteCommand<ExecuteMessage>(serverProxy, Guid.NewGuid());

                        TimeSpan elapsed = DateTime.Now - start;
                        timingsPerRound.Add(elapsed.TotalMilliseconds);

                        // give the server time to clear it's queue 
                        Thread.Sleep((int)Math.Round(elapsed.TotalMilliseconds) * 2);
                    }
                    string toAdd = string.Format("{0}, {1}", sb.Length, timingsPerRound.Sum() / roundsPerPacketStep);
                    Console.WriteLine(toAdd);
                    timings.Add(toAdd);
                    // build new packet that is incrementingFactor bigger than previous
                    StringBuilder tmpSb = new StringBuilder();
                    tmpSb.Append(sb);
                    Enumerable.Range(1, (int)Math.Ceiling(incrementingFactor)).ToList().ForEach(x =>
                    tmpSb.Append(tmpSb.ToString()));
                    sb.Append(tmpSb.ToString().Substring(0,
                        (int)((tmpSb.Length - sb.Length) * (incrementingFactor - 1))));
                }
            }
            File.WriteAllLines(outFileName, timings.ToArray());
            //Console.ReadKey();
        }
Ejemplo n.º 3
0
 public ServerExplorerVersionProxy(IEnvironmentConnection connection)
 {
     CommunicationControllerFactory = new CommunicationControllerFactory();
     _connection = connection;
 }