public ExternalAdmin(StreamSocket socket)
        {
            this.socketHandler = new SocketHandler(socket);

            this.socketHandler.OnMessageBytesReceived += SocketHandler_OnMessageBytesReceived;
            this.socketHandler.Start();
        }
        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;
        }