Skip to content

Commit 23528c9

Browse files
committed
Class QpServerOptions add virtual method 'CreateServer'.
1 parent d5270f9 commit 23528c9

File tree

14 files changed

+63
-19
lines changed

14 files changed

+63
-19
lines changed

QpTestClient/QuickConnectForm.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ private void btnOk_Click(object sender, EventArgs e)
5959
ConnectionInfo = new TestConnectionInfo()
6060
{
6161
Name = name,
62-
QpClientTypeName = options.GetQpClientType().FullName,
62+
QpClientTypeName = options.CreateClient().GetType().FullName,
6363
QpClientOptions = options
6464
};
6565
DialogResult = DialogResult.OK;

Quick.Protocol.Pipeline/QpPipelineClientOptions.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,11 @@ public override void Check()
2424
throw new ArgumentNullException(nameof(PipeName));
2525
}
2626

27-
public override Type GetQpClientType() => typeof(QpPipelineClient);
28-
27+
public override QpClient CreateClient()
28+
{
29+
return new QpPipelineClient(this);
30+
}
31+
2932
protected override void LoadFromUri(Uri uri)
3033
{
3134
ServerName =uri.Host;

Quick.Protocol.Pipeline/QpPipelineServerOptions.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,10 @@ public override void Check()
1414
if (string.IsNullOrEmpty(PipeName))
1515
throw new ArgumentNullException(nameof(PipeName));
1616
}
17+
18+
public override QpServer CreateServer()
19+
{
20+
return new QpPipelineServer(this);
21+
}
1722
}
1823
}

Quick.Protocol.SerialPort/QpSerialPortClientOptions.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,11 @@ public override void Check()
4747
throw new ArgumentNullException(nameof(PortName));
4848
}
4949

50-
public override Type GetQpClientType() => typeof(QpSerialPortClient);
51-
50+
public override QpClient CreateClient()
51+
{
52+
return new QpSerialPortClient(this);
53+
}
54+
5255
protected override void LoadFromUri(Uri uri)
5356
{
5457
PortName = uri.Host;

Quick.Protocol.SerialPort/QpSerialPortServerOptions.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
namespace Quick.Protocol.SerialPort
77
{
8-
public class QpSerialPortServerOptions: QpServerOptions
8+
public class QpSerialPortServerOptions : QpServerOptions
99
{
1010
/// <summary>
1111
/// 端口名称
@@ -34,5 +34,10 @@ public override void Check()
3434
if (string.IsNullOrEmpty(PortName))
3535
throw new ArgumentNullException(nameof(PortName));
3636
}
37+
38+
public override QpServer CreateServer()
39+
{
40+
return new QpSerialPortServer(this);
41+
}
3742
}
3843
}

Quick.Protocol.Tcp/QpTcpClientOptions.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,10 @@ public override void Check()
4242
throw new ArgumentException("Port must between 0 and 65535", nameof(Port));
4343
}
4444

45-
public override Type GetQpClientType() => typeof(QpTcpClient);
45+
public override QpClient CreateClient()
46+
{
47+
return new QpTcpClient(this);
48+
}
4649

4750
protected override void LoadFromUri(Uri uri)
4851
{

Quick.Protocol.Tcp/QpTcpServerOptions.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,10 @@ public override void Check()
2626
if (Port < 0 || Port > 65535)
2727
throw new ArgumentException("Port must between 0 and 65535", nameof(Port));
2828
}
29+
30+
public override QpServer CreateServer()
31+
{
32+
return new QpTcpServer(this);
33+
}
2934
}
3035
}

Quick.Protocol.Udp/QpUdpClientOptions.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,10 @@ public override void Check()
4242
throw new ArgumentException("Port must between 0 and 65535", nameof(Port));
4343
}
4444

45-
public override Type GetQpClientType() => typeof(QpUdpClient);
45+
public override QpClient CreateClient()
46+
{
47+
return new QpUdpClient(this);
48+
}
4649

4750
protected override void LoadFromUri(Uri uri)
4851
{

Quick.Protocol.Udp/QpUdpServerOptions.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,10 @@ public override void Check()
2626
if (Port < 0 || Port > 65535)
2727
throw new ArgumentException("Port must between 0 and 65535", nameof(Port));
2828
}
29+
30+
public override QpServer CreateServer()
31+
{
32+
return new QpUdpServer(this);
33+
}
2934
}
3035
}

Quick.Protocol.WebSocket.Client/QpWebSocketClientOptions.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@ public override void Check()
2626
throw new ArgumentException("Url must start with qp.ws:// or qp.wss://", nameof(Url));
2727
}
2828

29-
public override Type GetQpClientType() => typeof(QpWebSocketClient);
29+
public override QpClient CreateClient()
30+
{
31+
return new QpWebSocketClient(this);
32+
}
3033

3134
protected override void LoadFromUri(Uri uri)
3235
{

0 commit comments

Comments
 (0)