Esempio n. 1
0
    public void Update()
    {
        if (!transport.IsOpen)
        {
            return;
        }

        List <LogInfo> lstInfo = null;

        lock (_lstInfo)
        {
            int maxIndex = Math.Min(_lstInfo.Count, _maxPerFrame);
            lstInfo = _lstInfo.GetRange(0, maxIndex);
            _lstInfo.RemoveRange(0, maxIndex);
        }

        if (lstInfo.Count <= 0)
        {
            return;
        }

        try
        {
            client.send_log(lstInfo);
        }
        catch (System.Exception ex)
        {
            Debug.LogError("发送失败!");
            Debug.LogError(ex.Message);
        }
    }
Esempio n. 2
0
        public static void Main()
        {
            try
            {
                TTransport transport = new TSocket("localhost", 9090);
                TProtocol protocol = new TBinaryProtocol(transport);
                SendLog.Client client = new SendLog.Client(protocol);

                transport.Open();
                try
                {
                    Random ran = new Random();
                    string strContent = "";
                    List<LogInfo> lstLogInfo = new List<LogInfo>();
                    for (int i = 0; i < 1000; i++ )
                    {
                        LogInfo info = new LogInfo();
                        info.Content = strContent;
                        strContent += i;
                        info.DeviceName = i.ToString();
                        info.Time = (int)DateTime.UtcNow.Ticks;
                        info.Category = "category" + i;
                        lstLogInfo.Add(info);
                    }

                    client.send_log(lstLogInfo);
                }
                finally
                {
                    transport.Close();
                }
            }
            catch (TApplicationException x)
            {
                Console.WriteLine(x.StackTrace);
            }
        }
Esempio n. 3
0
        public static void Main()
        {
            try
            {
                TTransport     transport = new TSocket("localhost", 9090);
                TProtocol      protocol  = new TBinaryProtocol(transport);
                SendLog.Client client    = new SendLog.Client(protocol);

                transport.Open();
                try
                {
                    Random         ran        = new Random();
                    string         strContent = "";
                    List <LogInfo> lstLogInfo = new List <LogInfo>();
                    for (int i = 0; i < 1000; i++)
                    {
                        LogInfo info = new LogInfo();
                        info.Content    = strContent;
                        strContent     += i;
                        info.DeviceName = i.ToString();
                        info.Time       = (int)DateTime.UtcNow.Ticks;
                        info.Category   = "category" + i;
                        lstLogInfo.Add(info);
                    }

                    client.send_log(lstLogInfo);
                }
                finally
                {
                    transport.Close();
                }
            }
            catch (TApplicationException x)
            {
                Console.WriteLine(x.StackTrace);
            }
        }