Esempio n. 1
0
        public static AnkoData Load(Stream stream)
        {
            AnkoData configData = null;

            try
            {
                System.Xml.Serialization.XmlSerializer xs = new XmlSerializer(typeof(AnkoData));
                configData = xs.Deserialize(stream) as AnkoData;
            }
            catch { }

            return(configData != null ? configData : new AnkoData());
        }
Esempio n. 2
0
        private void TcpListenLoop()
        {
            while (enable)
            {
                try
                {
                    server = new TcpListener(System.Net.IPAddress.Any, config.port);

                    server.Start();

                    TcpClient adept = server.AcceptTcpClient();

                    NetworkStream ns = adept.GetStream();
                    ns.ReadTimeout  = 1000;
                    ns.WriteTimeout = 1000;

                    AnkoData ndata = AnkoData.Load(ns);

                    /*
                     * MemoryStream ms = new MemoryStream();
                     * byte[] resByte = new byte[256];
                     * int rsize = 0;
                     * do
                     * {
                     *      rsize = ns.Read(resByte, 0, resByte.Length);
                     *      if (rsize == 0)
                     *      {
                     *              break;
                     *      }
                     *      ms.Write(resByte, 0, rsize);
                     * } while (ns.DataAvailable || resByte[rsize - 1] != '\n');
                     *
                     * string resMsg = Encoding.UTF8.GetString(ms.GetBuffer(), 0, (int)ms.Length);//*/

                    adder.addTask(ndata.Message, ndata.AuthorID, ndata.AuthorName, "", this, "");

                    //ms.Close();

                    ns.Close();

                    adept.Close();

                    server.Stop();
                }
                catch { }
            }
        }