Пример #1
0
        /// <summary>
        /// 处理数据winsock到达事件
        /// </summary>
        /// <param name="bytesTotal"></param>
        private void _winsock_DataArrival(int bytesTotal)
        {
            try
            {
                //byte[] bs = new byte[bytesTotal];
                object bs = new byte[bytesTotal];
                _winsock.GetData(ref bs, _type, bytesTotal);

                // 2007.03.05 ?? Replace with a user define DataArrival event
                //
                //MessageBox.Show
                if (WSListen._log != null)
                {
                    WSListen._log.AddLog("from :" + _winsock.RemoteHostIP);
                    WSListen._log.AddLog(Utilities.CT.BytesToString((byte[])bs));
                }

                if (this.IsReceiving)
                {
                    m_ReceivedData = MergeBytes(m_ReceivedData, (byte[])bs);
                }
                else
                {
                    if (_IsEnableAutoReport)
                    {
                        _autoReportDatas = MergeBytes(_autoReportDatas, (byte[])bs);
                        if (this.ReceiveAutoReport != null)
                        {
                            System.EventHandler temp = this.ReceiveAutoReport;
                            temp(this, EventArgs.Empty);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.Fail("At _winsock_DataArrival", ex.ToString());
            }
        }