private async Task SendMessage(string method, string message, MessageTier nextMessageTier) { // Treat the default None as continuing the same tier from the current tier state. if (nextMessageTier == MessageTier.None) { nextMessageTier = _messageTier; } var treeLine = _messageTier switch { MessageTier.End when nextMessageTier == MessageTier.Single || nextMessageTier == (MessageTier.End | MessageTier.Single) => "┬─", MessageTier.End when nextMessageTier == MessageTier.Double => "┬┬", MessageTier.End when nextMessageTier == MessageTier.End => "──", MessageTier.Double when nextMessageTier == MessageTier.Double => "│├─", MessageTier.Double when nextMessageTier == MessageTier.End => "└┴─", MessageTier.Double when nextMessageTier == (MessageTier.End | MessageTier.Single) => "│└─", MessageTier.Single when nextMessageTier == MessageTier.Single || nextMessageTier == (MessageTier.End | MessageTier.Single) => "├─", MessageTier.Single when nextMessageTier == MessageTier.Double => "├┬", MessageTier.Single when nextMessageTier == MessageTier.End => "└─", _ => throw new InvalidOperationException($"{nextMessageTier} is an invalid next tier for current tier {_messageTier}.") }; _messageTier = nextMessageTier == (MessageTier.End | MessageTier.Single) ? MessageTier.Single : nextMessageTier; var tieredMessage = message.Insert(0, treeLine); _logger.LogDebug(tieredMessage); await _hub.Clients.All.SendAsync(method, new Message { Timestamp = DateTime.Now, Text = method == ReceiveTxMessageMethod ? tieredMessage : message }); }
public async Task SendTxMessage(string message, MessageTier nextMessageTier = MessageTier.None) => await SendMessage(ReceiveTxMessageMethod, message, nextMessageTier);