private SemaphoreSlim _semaphore = new SemaphoreSlim(1, 1);
public async Task SendAsync(string message)
{
if (_ws.State != WebSocketState.Open)
throw new Exception("Connection is not open");
try
{
await _semaphore.WaitAsync().ConfigureAwait(false);
var cancel = new CancellationTokenSource(5000);
var bytes = new ArraySegment<byte>(Encoding.UTF8.GetBytes(message));
await _ws.SendAsync(bytes, WebSocketMessageType.Text, true, cancel.Token).ConfigureAwait(false);
}
finally
{
_semaphore.Release();
}
}
我得到错误:TypeError:无法读取未定义的属性“ lenght” 谁能帮我! 感谢高级。