squash a bunch of commits

This commit is contained in:
2022-10-30 12:03:16 -05:00
parent 09b72c1858
commit 93027e8c57
222 changed files with 6157 additions and 3201 deletions

View File

@@ -0,0 +1,21 @@
using System.Net.WebSockets;
using System.Text;
namespace Shogi.Api.Extensions
{
public static class WebSocketExtensions
{
public static async Task SendTextAsync(this WebSocket self, string message)
{
await self.SendAsync(Encoding.UTF8.GetBytes(message), WebSocketMessageType.Text, true, CancellationToken.None);
}
public static async Task<string> ReceiveTextAsync(this WebSocket self)
{
var buffer = new ArraySegment<byte>(new byte[2048]);
var receive = await self.ReceiveAsync(buffer, CancellationToken.None);
return Encoding.UTF8.GetString(buffer.Slice(0, receive.Count));
// TODO: Make this robust to multi-frame messages.
}
}
}