private async Task <string> ReceiveAsync(ClientWebSocket webSocket) { // TODO: Probably should optimize this (better resource allocation/management) byte[] temporaryBuffer = new byte[8192]; byte[] buffer = new byte[8192 * 16]; int offset = 0; bool end = false; while (!end) { WebSocketReceiveResult result = await webSocket.ReceiveAsync(new ArraySegment <byte>(temporaryBuffer), CancellationToken.None); if (result.MessageType == WebSocketMessageType.Close) { OnClosed?.InvokeAsync(result.CloseStatus, result.CloseStatusDescription); Connected = false; manager.logger.Log($"Disconnected from Lavalink node ({(int)result.CloseStatus}, {result.CloseStatusDescription})", LogSeverity.Info); } else { temporaryBuffer.CopyTo(buffer, offset); offset += result.Count; temporaryBuffer = new byte[8192]; if (result.EndOfMessage) { end = true; } } } return(Encoding.UTF8.GetString(buffer)); }
/// <summary> /// Close picker popup /// </summary> public async Task Close() { await LeftCalendar.CalculateCalendar(); await RightCalendar.CalculateCalendar(); Visible = false; await OnClosed.InvokeAsync(null); }
/// <summary> /// Close picker popup /// </summary> public void Close() { Visible = false; StateHasChanged(); OnClosed.InvokeAsync(null); }
public void Close() { OnClosed.InvokeAsync(); }