public static async ValueTask SendTo(this DataLinkCollection dlc, string peer, string group, string content) { var length = Encoding.UTF8.GetByteCount(content); using (var owner = ExactSizeMemoryPool.Shared.Rent(length)) { Encoding.UTF8.GetBytes(content, owner.Memory.Span); await dlc.SendTo(peer, group, owner.Memory); } }
private async Task SendToPeer(string line) { var param = line.Substring(2).Trim(); var parts = param.Split(' ', 2); if (parts.Length == 2) { await _dlc.SendTo(parts[0], P2PChannel, parts[1]); } else { Console.WriteLine("Bad command."); } }