mirror of
https://github.com/ZetaKebab/MpcNET.git
synced 2025-01-14 22:18:43 +00:00
Send only single command to MPD.
This commit is contained in:
parent
7068ac9db0
commit
fe55423be2
@ -1,7 +1,7 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace LibMpc
|
namespace LibMpc
|
||||||
@ -14,6 +14,7 @@ namespace LibMpc
|
|||||||
{
|
{
|
||||||
private static readonly Regex STATUS_AUDIO_REGEX = new Regex("^(?<sampleRate>[0-9]*):(?<bits>[0-9]*):(?<channels>[0-9]*)$");
|
private static readonly Regex STATUS_AUDIO_REGEX = new Regex("^(?<sampleRate>[0-9]*):(?<bits>[0-9]*):(?<channels>[0-9]*)$");
|
||||||
|
|
||||||
|
private readonly SemaphoreSlim _semaphore = new SemaphoreSlim(1, 1);
|
||||||
private readonly IPEndPoint _server;
|
private readonly IPEndPoint _server;
|
||||||
private MpcConnection _connection;
|
private MpcConnection _connection;
|
||||||
|
|
||||||
@ -54,9 +55,15 @@ namespace LibMpc
|
|||||||
|
|
||||||
public async Task<IMpdMessage<T>> SendAsync<T>(IMpcCommand<T> command)
|
public async Task<IMpdMessage<T>> SendAsync<T>(IMpcCommand<T> command)
|
||||||
{
|
{
|
||||||
var mpdMessage = await _connection.SendAsync(command);
|
await _semaphore.WaitAsync();
|
||||||
|
try
|
||||||
return mpdMessage;
|
{
|
||||||
|
return await _connection.SendAsync(command);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
_semaphore.Release();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user