Beispiel #1
0
        /// <summary>
        /// 监控文件管理逻辑信息
        /// </summary>
        private void ShowMonitorInfo()
        {
            new Thread(new ThreadStart(() =>
            {
                string result;

                long oldSended   = 0;
                long oldRecevied = 0;

                long s_speed = 0;
                long r_speed = 0;

                while (true)
                {
                    result = string.Empty;

                    while (true)
                    {
                        if (_beginSend && _beginReceive)
                        {
                            s_speed   = _sender.Out - oldSended;
                            oldSended = _sender.Out;

                            r_speed     = _receiver.In - oldRecevied;
                            oldRecevied = _receiver.In;

                            result = string.Format("总数:{0} 已发送:{1} 发送速度:{2}/s 接收:{3} 接收速度:{4}/s", _receiver.Total.ToFString(), _sender.Out.ToFString(), s_speed.ToFString(), _receiver.In.ToFString(), r_speed.ToFString());
                        }
                        else if (_beginSend)
                        {
                            s_speed   = _sender.Out - oldSended;
                            oldSended = _sender.Out;

                            result = string.Format("总数:{0} 发送:{1} 发送速度:{2}/s", _sender.Total.ToFString(), _sender.Out.ToFString(), s_speed.ToFString());
                        }
                        else if (_beginReceive)
                        {
                            r_speed     = _receiver.In - oldRecevied;
                            oldRecevied = _receiver.In;

                            result = string.Format("总数:{0} 接收:{1} 接收速度:{2}/s", _receiver.Total.ToFString(), _receiver.In.ToFString(), r_speed.ToFString());
                        }
                        else
                        {
                            break;
                        }

                        if (!string.IsNullOrEmpty(result))
                        {
                            OnSending?.Invoke(result);
                        }
                        Thread.Sleep(1000);
                    }
                    Thread.Sleep(1000);
                }
            }))
            {
                IsBackground = true
            }.Start();
        }
Beispiel #2
0
        public void Send(Buffers.WebSocket.Write buffer)
        {
            var parsed = buffer.Parsed;

            Socket.BeginSend(parsed, 0, parsed.Length, 0, beginSend, buffer);
            OnSending?.Invoke();
        }