Exemplo n.º 1
0
 public override void OnData(IObjectContainer container,AppSocketSession session, AppSocketData data)
 {
     try
     {
         container.Resolve<IRawDataService>().Log(session, ByteHelper.ConvertBytesToStringByHex(data.RawData, ","));
     }
     catch (Exception ex)
     {
         container.Resolve<ILogger>().Error("记录原始数据错误", ex);
     }
 }
Exemplo n.º 2
0
 public override void OnData(IObjectContainer container,AppSocketSession session, AppSocketData data)
 {
     try
     {
         container.Resolve<IRawDataService>().Log(session, Encoding.UTF8.GetString(data.RawData));
     }
     catch (Exception ex)
     {
         container.Resolve<ILogger>().Error("记录原始数据错误", ex);
     }
 }
Exemplo n.º 3
0
        public override void OnData(IObjectContainer container,AppSocketSession session, AppSocketData data)
        {
            try
            {
                var log = string.Empty;
                if (data.RawData[0] == 0x2a)
                {
                    log = Encoding.ASCII.GetString(data.RawData);
                }
                else
                {
                    log = ByteHelper.ConvertBytesToStringByHex(data.RawData, ",");
                }

                container.Resolve<IRawDataService>().Log(session, log);
            }
            catch (Exception ex)
            {
                container.Resolve<ILogger>().Error("记录原始数据错误", ex);
            }
        }
Exemplo n.º 4
0
 protected virtual void OnReceiveData(ReceivedDataArgs receiveDataArgs)
 {
     try
     {
         AppSocketData data = new AppSocketData(receiveDataArgs.RawData);
         _socketServerEvent.OnData(AppSocketContainer.Ins, receiveDataArgs.Session, data);
         _socketDataProcessor.Handle(receiveDataArgs.Session, data);
     }
     catch (Exception ex)
     {
         _logger.Error(ex);
     }
 }
Exemplo n.º 5
0
 protected virtual void OnReceiveData(ReceivedDataArgs receiveDataArgs)
 {
     try
     {
         AppSocketData data = new AppSocketData(receiveDataArgs.RawData);
         if (_serverConfig.LogRawData && receiveDataArgs.RawData.Length > 0)
         {
             _socketServerEvent.OnLogRawData(AppSocketContainer.Ins, data);
         }
         _socketDataProcessor.Handle(receiveDataArgs.Session, data);
     }
     catch (Exception ex)
     {
         _logger.Error(ex);
     }
 }
Exemplo n.º 6
0
 public virtual void Handle(AppSocketSession session,AppSocketData data)
 {
     _socketProtocol.Excute(session, data);
 }
Exemplo n.º 7
0
 /// <summary>
 /// 记录原始数据 接收到数据的时候执行
 /// </summary>
 /// <param name="container"></param>
 /// <param name="data">原始数据</param>
 public virtual void OnLogRawData(AppSocketContainer container, AppSocketData data)
 {
     container.Resolve<ILogger>().Info(string.Join(" ", data.RawData.Select(p => p.ToString("X2"))));
 }