-
Notifications
You must be signed in to change notification settings - Fork 8
/
TcpHandlerServer.cs
65 lines (63 loc) · 2.33 KB
/
TcpHandlerServer.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
using PHS.Networking.Events.Args;
using System;
using Tcp.NET.Core.Models;
using Tcp.NET.Server.Events.Args;
using Tcp.NET.Server.Models;
namespace Tcp.NET.Server.Handlers
{
public class TcpHandlerServer :
TcpHandlerServerBase<
TcpConnectionServerEventArgs,
TcpMessageServerEventArgs,
TcpErrorServerEventArgs,
IParamsTcpServer,
ConnectionTcpServer>
{
public TcpHandlerServer(IParamsTcpServer parameters) : base(parameters)
{
}
public TcpHandlerServer(IParamsTcpServer parameters, byte[] certificate, string certificatePassword) : base(parameters, certificate, certificatePassword)
{
}
protected override ConnectionTcpServer CreateConnection(ConnectionTcpServer connection)
{
return new ConnectionTcpServer
{
TcpClient = connection.TcpClient,
ConnectionId = Guid.NewGuid().ToString(),
SslStream = connection.SslStream,
ReadBuffer = connection.ReadBuffer
};
}
protected override TcpConnectionServerEventArgs CreateConnectionEventArgs(ConnectionEventArgs<ConnectionTcpServer> args)
{
return new TcpConnectionServerEventArgs
{
Connection = args.Connection,
ConnectionEventType = args.ConnectionEventType,
CancellationToken = args.CancellationToken,
};
}
protected override TcpMessageServerEventArgs CreateMessageEventArgs(TcpMessageServerBaseEventArgs<ConnectionTcpServer> args)
{
return new TcpMessageServerEventArgs
{
Connection = args.Connection,
Bytes = args.Bytes,
Message = args.Message,
MessageEventType = args.MessageEventType,
CancellationToken = args.CancellationToken
};
}
protected override TcpErrorServerEventArgs CreateErrorEventArgs(ErrorEventArgs<ConnectionTcpServer> args)
{
return new TcpErrorServerEventArgs
{
Connection = args.Connection,
Exception = args.Exception,
Message = args.Message,
CancellationToken = args.CancellationToken
};
}
}
}