Implement IDisposable for CommandStream

This commit is contained in:
2019-04-27 13:59:01 +02:00
parent 76bbefd729
commit 7467d5ba81
4 changed files with 38 additions and 32 deletions

View File

@@ -21,10 +21,7 @@ namespace PlantBox.Client.ViewModels
public HomeViewModel()
{
var ids = App.Settings.IDs.ToList();
ids.Add(152);
Plants = LoadPlants(ids);
Plants = LoadPlants(App.Settings.IDs);
}
public ObservableCollection<PlantInfo> LoadPlants(IEnumerable<ulong> ids)
@@ -42,8 +39,8 @@ namespace PlantBox.Client.ViewModels
private IEnumerable<PlantInfo> GetPlantInfos(IEnumerable<ulong> ids)
{
using (var client = new TcpClient(App.Settings.BrokerIP, Connection.TCP_CLIENT_PORT))
using (var stream = new CommandStream(client.GetStream()))
{
var stream = new CommandStream(client.GetStream());
foreach (ulong id in ids)
{

View File

@@ -123,8 +123,8 @@ namespace PlantBox.Client.ViewModels
private void LoadValues()
{
using (var client = new TcpClient(App.Settings.BrokerIP, Connection.TCP_CLIENT_PORT))
using (var stream = new CommandStream(client.GetStream()))
{
var stream = new CommandStream(client.GetStream());
// Captors info
stream.Send(new CaptorsRequest().ToCommandPacket(PlantInfo.ID));