Implement IDisposable for CommandStream
This commit is contained in:
@@ -52,36 +52,37 @@ namespace PlantBox.Broker
|
||||
|
||||
private void ClientLoop(TcpClient client)
|
||||
{
|
||||
var commandStream = new CommandStream(client.GetStream());
|
||||
|
||||
try
|
||||
using (var commandStream = new CommandStream(client.GetStream()))
|
||||
{
|
||||
while (client.Connected)
|
||||
try
|
||||
{
|
||||
var packet = commandStream.Receive();
|
||||
Log($"Received command from {client.Client.RemoteEndPoint}");
|
||||
Log(packet.ToString());
|
||||
|
||||
switch (packet.Command)
|
||||
while (client.Connected)
|
||||
{
|
||||
case Command.Captors:
|
||||
CaptorsCommand(commandStream, packet);
|
||||
break;
|
||||
case Command.Historic:
|
||||
HistoricCommand(commandStream, packet);
|
||||
break;
|
||||
case Command.Info:
|
||||
InfoCommand(commandStream, packet);
|
||||
break;
|
||||
case Command.Ping:
|
||||
PingCommand(commandStream, packet);
|
||||
break;
|
||||
var packet = commandStream.Receive();
|
||||
Log($"Received command from {client.Client.RemoteEndPoint}");
|
||||
Log(packet.ToString());
|
||||
|
||||
switch (packet.Command)
|
||||
{
|
||||
case Command.Captors:
|
||||
CaptorsCommand(commandStream, packet);
|
||||
break;
|
||||
case Command.Historic:
|
||||
HistoricCommand(commandStream, packet);
|
||||
break;
|
||||
case Command.Info:
|
||||
InfoCommand(commandStream, packet);
|
||||
break;
|
||||
case Command.Ping:
|
||||
PingCommand(commandStream, packet);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log($"Client disconnected: {ex.Message}");
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log($"Client disconnected: {ex.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user