protected override void OnReceived(byte[] buffer, long offset, long size)
 {
     try
     {
         Log.WriteLog(LogType.Info, "TcpClientNetwork| OnReceived", $"Received Data");
         ReceiveFromPeer?.Invoke(buffer, offset, size);
     }
     catch (Exception ex)
     {
         Log.WriteLog(LogType.Error, $"TcpClientNetwork| OnReceived", $"Received error : {ex.Message}");
     }
 }
Esempio n. 2
0
 /// <summary>
 /// 데이터 수신
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void RecevieData(object sender, MessageEventArgs e)
 {
     try
     {
         byte[] rcvData = e.RawData;
         ReceiveFromPeer?.Invoke(rcvData, 0, rcvData.Length);
     }
     catch (Exception ex)
     {
         Log.WriteLog(LogType.Error, $"NetworkWSSClient| RecevieData", $"Received error : {ex.Message}");
     }
 }
        protected override void SerialPort_DataReceived(object sender, SerialDataReceivedEventArgs e)
        {
            //Thread.Sleep(800); //SerialPort로부터 Data가 모두 전달되기까지 좀 기다려야 함.
            int         length      = SerialPort.BytesToRead;
            List <byte> mReadBuffer = new List <byte>();

            for (int i = 0; i < length; i++)
            {
                mReadBuffer.Add((byte)SerialPort.ReadByte());
            }

            //Log.WriteLog(LogType.Info, $"SerialNetwork | SerialPort_DataReceived", $"데이터 수신");

            ReceiveFromPeer?.Invoke(mReadBuffer.ToArray(), 0, mReadBuffer.Count);
            mStep = ProtocolStep.Ready;
        }