-
Notifications
You must be signed in to change notification settings - Fork 8
/
TcpNETServer.cs
74 lines (67 loc) · 2.44 KB
/
TcpNETServer.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
using Tcp.NET.Server.Models;
using Tcp.NET.Server.Handlers;
using Tcp.NET.Server.Managers;
using Tcp.NET.Server.Events.Args;
namespace Tcp.NET.Server
{
public class TcpNETServer :
TcpNETServerBase<
TcpConnectionServerEventArgs,
TcpMessageServerEventArgs,
TcpErrorServerEventArgs,
IParamsTcpServer,
TcpHandlerServer,
TcpConnectionManager,
ConnectionTcpServer>,
ITcpNETServer
{
public TcpNETServer(IParamsTcpServer parameters) : base(parameters)
{
}
public TcpNETServer(IParamsTcpServer parameters,
byte[] certificate,
string certificatePassword) : base(parameters, certificate, certificatePassword)
{
}
protected override TcpConnectionManager CreateConnectionManager()
{
return new TcpConnectionManager();
}
protected override TcpHandlerServer CreateHandler()
{
return _certificate != null
? new TcpHandlerServer(_parameters, _certificate, _certificatePassword)
: new TcpHandlerServer(_parameters);
}
protected override TcpErrorServerEventArgs CreateErrorEventArgs(TcpErrorServerBaseEventArgs<ConnectionTcpServer> args)
{
return new TcpErrorServerEventArgs
{
Connection = args.Connection,
Exception = args.Exception,
Message = args.Message,
CancellationToken = args.CancellationToken
};
}
protected override TcpConnectionServerEventArgs CreateConnectionEventArgs(TcpConnectionServerBaseEventArgs<ConnectionTcpServer> args)
{
return new TcpConnectionServerEventArgs
{
Connection = args.Connection,
ConnectionEventType = args.ConnectionEventType,
CancellationToken = args.CancellationToken
};
}
protected override TcpMessageServerEventArgs CreateMessageEventArgs(TcpMessageServerBaseEventArgs<ConnectionTcpServer> args)
{
return new TcpMessageServerEventArgs
{
Bytes = args.Bytes,
Connection = args.Connection,
Message = args.Message,
MessageEventType = args.MessageEventType,
CancellationToken = args.CancellationToken
};
}
}
}