Ejemplo n.º 1
0
        public bool Start()
        {
            _server.ClientConnected += (socket, id) => _agency.Register(new TestAgentTcpProxy(socket, id));
            _server.Start();

            return(true);
        }
Ejemplo n.º 2
0
        public bool Start()
        {
            log.Info("Agent starting");

            // Open the TCP channel so we can activate an ITestAgency instance from _agencyUrl
            _channel = TcpChannelUtils.GetTcpChannel(_currentMessageCounter);

            log.Info("Connecting to TestAgency at {0}", _agencyUrl);
            try
            {
                // Direct cast, not safe cast. If the cast fails we need a clear InvalidCastException message, not a null _agency.
                _agency = (ITestAgency)Activator.GetObject(typeof(ITestAgency), _agencyUrl);
            }
            catch (Exception ex)
            {
                log.Error("Unable to connect: {0}", ExceptionHelper.BuildMessageAndStackTrace(ex));
            }

            try
            {
                _agency.Register(_agentId, this);
                log.Debug("Registered with TestAgency");
            }
            catch (Exception ex)
            {
                log.Error("RemoteTestAgent: Failed to register with TestAgency. {0}", ExceptionHelper.BuildMessageAndStackTrace(ex));
                return(false);
            }

            return(true);
        }
 public void Register(ITestAgent agent)
 {
     _agency.Register(agent);
 }