/// <summary>
        /// Send a list of results to server
        /// </summary>
        /// <param name="ip">Server IP</param>
        /// <param name="port">Server Port</param>
        /// <param name="listResults">List of results to send</param>
        public DataResult(string ip, int port, List<Task> listResults)
        {
            List<byte[]> listWorksToSend = new List<byte[]>();
            listResults.Sort();
            /*Connect to client*/
            Sender s = new Sender(ip, Convert.ToInt32(port));
            foreach (Task item in listResults)
            {
                /*Add info of data*/
                if (item.data != null)
                {
                    PacketInfo packetInfo = new PacketInfo(Command.Result, item.noPacket, "", item.data.Length,item.secondSince1970,item.issueNumber);
                    listWorksToSend.Add(packetInfo.ToByte());
                    /*Add data*/
                    listWorksToSend.Add(item.data);
                }
            }
            /*Assembly the packets*/
            PacketAssembler packetAssembler = new PacketAssembler();
            byte[] dataToSend = packetAssembler.Assemble(listWorksToSend);
            listResults.Clear();

            /*Send data to client*/
            s.send(dataToSend);
        }
Пример #2
0
        /// <summary>
        /// Send a list of results to server
        /// </summary>
        /// <param name="ip">Server IP</param>
        /// <param name="port">Server Port</param>
        /// <param name="listResults">List of results to send</param>
        public DataResult(string ip, int port, List <Task> listResults)
        {
            List <byte[]> listWorksToSend = new List <byte[]>();

            listResults.Sort();
            /*Connect to client*/
            Sender s = new Sender(ip, Convert.ToInt32(port));

            foreach (Task item in listResults)
            {
                /*Add info of data*/
                if (item.data != null)
                {
                    PacketInfo packetInfo = new PacketInfo(Command.Result, item.noPacket, "", item.data.Length, item.secondSince1970, item.issueNumber);
                    listWorksToSend.Add(packetInfo.ToByte());
                    /*Add data*/
                    listWorksToSend.Add(item.data);
                }
            }
            /*Assembly the packets*/
            PacketAssembler packetAssembler = new PacketAssembler();

            byte[] dataToSend = packetAssembler.Assemble(listWorksToSend);
            listResults.Clear();

            /*Send data to client*/
            s.send(dataToSend);
        }
Пример #3
0
        /// <summary>
        /// Send data init to server
        /// </summary>
        /// <param name="ip">IP of server</param>
        /// <param name="port">Listen port of server</param>
        /// <param name="init">Packet Init</param>
        public DataInit(string ip, int port, Init init)
        {
            try
            {
                List<byte[]> listPacketInit = new List<byte[]>();
                /*Connect to client*/
                Sender s = new Sender(ip, Convert.ToInt32(port));

                byte[] dataToSend = init.ToByte();
                /*Add info of data*/
                PacketInfo packetInfo = new PacketInfo(Command.Init, 0, "", dataToSend.Length,0,0);
                listPacketInit.Add(packetInfo.ToByte());
                /*Add data*/
                listPacketInit.Add(dataToSend);
                /*Assembly the packets*/
                PacketAssembler packetAssembler = new PacketAssembler();
                dataToSend = packetAssembler.Assemble(listPacketInit);

                /*Send data to client*/
                s.send(dataToSend);
            }
            catch { }
        }
Пример #4
0
        /// <summary>
        /// Send data init to server
        /// </summary>
        /// <param name="ip">IP of server</param>
        /// <param name="port">Listen port of server</param>
        /// <param name="init">Packet Init</param>
        public DataInit(string ip, int port, Init init)
        {
            try
            {
                List <byte[]> listPacketInit = new List <byte[]>();
                /*Connect to client*/
                Sender s = new Sender(ip, Convert.ToInt32(port));

                byte[] dataToSend = init.ToByte();
                /*Add info of data*/
                PacketInfo packetInfo = new PacketInfo(Command.Init, 0, "", dataToSend.Length, 0, 0);
                listPacketInit.Add(packetInfo.ToByte());
                /*Add data*/
                listPacketInit.Add(dataToSend);
                /*Assembly the packets*/
                PacketAssembler packetAssembler = new PacketAssembler();
                dataToSend = packetAssembler.Assemble(listPacketInit);

                /*Send data to client*/
                s.send(dataToSend);
            }
            catch { }
        }