Skip to content

Commit 6328378

Browse files
committed
Change QpSerialPortServer accept interval from 1000ms to 100ms.
1 parent 44e0dad commit 6328378

File tree

4 files changed

+4
-3
lines changed

4 files changed

+4
-3
lines changed

Quick.Protocol.SerialPort/QpSerialPortClient.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ public override void Disconnect()
3939
{
4040
if (serialPort != null)
4141
{
42+
serialPort.Close();
4243
serialPort.Dispose();
4344
serialPort = null;
4445
}

Quick.Protocol.SerialPort/QpSerialPortServer.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public override void Stop()
4141
base.Stop();
4242
if (serialPort != null)
4343
{
44+
serialPort.Close();
4445
serialPort.Dispose();
4546
serialPort = null;
4647
}
@@ -55,7 +56,7 @@ private void QpSerialPortServer_ChannelDisconnected(object sender, QpServerChann
5556
protected override Task InnerAcceptAsync(CancellationToken token)
5657
{
5758
if (isAccepted)
58-
return Task.Delay(1000, token);
59+
return Task.Delay(100, token);
5960
isAccepted = true;
6061

6162
return Task.Run(() =>

Quick.Protocol/QpChannel.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ public virtual void Disconnect()
123123
if (IsConnected)
124124
{
125125
IsConnected = false;
126+
InitQpPackageHandler_Stream(null);
126127
Disconnected?.Invoke(this, QpEventArgs.Empty);
127128
}
128129
}

Quick.Protocol/QpServer.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,6 @@ protected void OnNewChannelConnected(Stream stream, string channelName, Cancella
8888
if (LogUtils.LogConnection)
8989
LogUtils.Log("[Connection]{0} Disconnected.", channelName);
9090
RemoveChannel(channel);
91-
try { stream.Dispose(); }
92-
catch { }
9391
ChannelDisconnected?.Invoke(this, channel);
9492
};
9593
};

0 commit comments

Comments
 (0)