/// <summary> /// Receives and adds the next incomming instruction to the incomming-queue. /// </summary> protected void AsyncInstructionReceiveNext() { buffer = new byte[bufferSize]; int received = LocalSocket.Receive(buffer, SocketFlags.None); if (received == 0) { return; } byte[] data = new byte[received]; Array.Copy(buffer, data, received); string text = Encoding.UTF8.GetString(data); Debug("Received Message.", DebugType.Info); try { InstructionBase[] instructionList = InstructionOperations.Parse(this, null, text).ToArray(); foreach (InstructionBase instr in instructionList) { incommingInstructions.Add(instr); } } catch (NetComAuthenticationException ex) { Debug("Authentication-Error.", DebugType.Error); if (ShowExceptions) { Debug($"({ex.GetType().Name}) {ex.Message}", DebugType.Exception); } } catch (Exception ex) { Debug($"Error occured. ({_logErrorCount})", DebugType.Error); if (ShowExceptions) { Debug($"({ex.GetType().Name}) {ex.Message}", DebugType.Exception); } _logErrorCount++; } }