Esempio n. 1
0
 public void ClientOnPackageReceived(IPacketInfo packet)
 {
     try
     {
         var offsets = PacketInfo.GetOffsetInfo(packet.Buffer, packet.Offset);
         foreach (var item in offsets)
         {
             try
             {
                 var operationCode = MessageBase.GetOperationCode(packet.Buffer, item.Offset);
                 if (operationCode != ShamanOperationCode.Bundle)
                 {
                     _logger.Debug($"Shaman message received. Operation code: {operationCode}");
                     _shamanMessageHandler.ProcessMessage(operationCode, packet.Buffer, item.Offset, item.Length);
                 }
                 else
                 {
                     _logger.Debug($"Bundle message received. Operation code: {operationCode}");
                     var bundleOperationCode = MessageBase.GetOperationCode(packet.Buffer, item.Offset + 1);
                     _bundleMessageHandler.ProcessMessage(bundleOperationCode, packet.Buffer, item.Offset + 1, item.Length - 1);
                 }
             }
             catch (Exception ex)
             {
                 _logger.Error(ex);
                 SetAndReportStatus(_status, _statusCallback, false, ex.Message);
             }
         }
     }
     finally
     {
         packet.Dispose();
     }
 }
Esempio n. 2
0
 private void ClientOnPackageReceived(IPacketInfo packet)
 {
     lock (_syncCollection)
     {
         var offsets = PacketInfo.GetOffsetInfo(packet.Buffer, packet.Offset);
         foreach (var item in offsets)
         {
             try
             {
                 ProcessMessage(packet.Buffer, item.Offset, item.Length);
             }
             catch (Exception ex)
             {
                 _logger.Error($"Error processing message: {ex}");
             }
         }
         packet.Dispose();
     }
 }