private void Selector_OnAgentNotReachable(AgentSelector sender, Agent agent)
 {
     if (this.OnAgentNotReachable != null)
     {
         this.OnAgentNotReachable(sender.JobToDo, agent);
     }
 }
        public async Task<WorkingAgent> GetCompatibleAgentFromList(RenderConfiguration configuration, List<Agent> list)
        {
            WorkingAgent compatible = null;            

            foreach (Agent info in list)
            {
                if (compatible == null)
                {
                    WorkingAgent worker = new WorkingAgent(configuration);

                    try
                    {
                        RenderMessage msg = await worker.Connect(info);

                        if (msg == RenderMessage.Supported)
                        {
                            compatible = worker;
                            this.currentCompatibleAgent = info;
                        }
                    }
                    catch (AgentNotReachableException)
                    {
                        if (this.OnAgentNotReachable != null)
                        {
                            this.OnAgentNotReachable(this, info);
                        }
                    }
                }
            }

            return compatible;
        }
        public async Task<RenderMessage> Connect(Agent agent)
        {
            Client c = new Client();
            StreamSocket socket;

            try
            {
                socket = await c.Connect(agent.IP, NetworkConfiguration.PortAgent, CONNECT_TIMEOUT);
            }
            catch (Exception)
            {
                throw new AgentNotReachableException("The agent could not be found!");
            }

            // send render job request
            RCS_Render_Job jobRequest = new RCS_Render_Job(this.Configuration, RemoteType.Client);

            byte[] sendData = Remote_Content_Show_MessageGenerator.GetMessageAsByte(jobRequest);

            this.socketHandler = new SocketHandler(socket);

            this.socketHandler.SendMessage(MessageCode.MC_Render_Job, sendData);

            // receive render job response
            SocketHandler.SocketMessage socketMsg;
            socketMsg.Code = MessageCode.MC_Alive;
            socketMsg.Content = new byte[] { };
            socketMsg.Empty = true;

            socketMsg = await this.socketHandler.WaitForMessage();

            // if he sends some invalid data, give him another chance.
            if (!socketMsg.Empty && socketMsg.Code != MessageCode.MC_Render_Job_Message)
            {
                socketMsg = await this.socketHandler.WaitForMessage();
            }

            if (!socketMsg.Empty)
            {
                RCS_Render_Job_Message jobResponse = Remote_Content_Show_MessageGenerator.GetMessageFromByte<RCS_Render_Job_Message>(socketMsg.Content);

                if (jobResponse.Message == RenderMessage.Supported)
                {
                    this.Agent = agent;
                    //this.socketHandler = new SocketHandler(socket);

                    this.socketHandler.OnMessageBytesReceived += SocketHandler_OnMessageBytesReceived;
                    this.socketHandler.OnConnectionLost += SocketHandler_OnConnectionLost;
                    this.socketHandler.Start();

                    this.Working = true;

                    this.lastKeepAlive = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond;
                    this.KeepAlive();
                }

                return jobResponse.Message;
            }

            // okay, he is not able to communicate.
            this.socketHandler.Close();

            return RenderMessage.NotSupported;
        }
示例#4
0
        private void Manager_OnAgentNotReachable(Job job, Agent agent)
        {
            //throw new NotImplementedException();
            string errorText = string.Empty;

            errorText += "Error while handling job " + job.OrderingNumber + " (" + job.Resource.Name + "): ";
            errorText += "The agent " + agent.IP.ToString() + " is offline.";

            EventsManager.Log(Job_EventType.Error, this.Configuration, errorText);
        }
示例#5
0
        private void Manager_OnAgentAborted(Job job, Agent agent)
        {
            string errorText = string.Empty;

            errorText += "Error while handling job " + job.OrderingNumber + " (" + job.Resource.Name + "): ";
            errorText += "The agent aborted the execution of the given resource.";

            EventsManager.Log(Job_EventType.Error, this.Configuration, errorText);
        }