/
ChannelHandlerAdapter.cs
86 lines (63 loc) · 3.13 KB
/
ChannelHandlerAdapter.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
75
76
77
78
79
80
81
82
83
84
85
86
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
namespace DotNetty.Transport.Channels
{
using System;
using System.Net;
using System.Threading.Tasks;
using DotNetty.Common.Utilities;
public class ChannelHandlerAdapter : IChannelHandler
{
internal bool Added;
[Skip]
public virtual void ChannelRegistered(IChannelHandlerContext context) => context.FireChannelRegistered();
[Skip]
public virtual void ChannelUnregistered(IChannelHandlerContext context) => context.FireChannelUnregistered();
[Skip]
public virtual void ChannelActive(IChannelHandlerContext context) => context.FireChannelActive();
[Skip]
public virtual void ChannelInactive(IChannelHandlerContext context) => context.FireChannelInactive();
[Skip]
public virtual void ChannelRead(IChannelHandlerContext context, object message) => context.FireChannelRead(message);
[Skip]
public virtual void ChannelReadComplete(IChannelHandlerContext context) => context.FireChannelReadComplete();
[Skip]
public virtual void ChannelWritabilityChanged(IChannelHandlerContext context) => context.FireChannelWritabilityChanged();
[Skip]
public virtual void HandlerAdded(IChannelHandlerContext context)
{
}
[Skip]
public virtual void HandlerRemoved(IChannelHandlerContext context)
{
}
[Skip]
public virtual void UserEventTriggered(IChannelHandlerContext context, object evt) => context.FireUserEventTriggered(evt);
[Skip]
public virtual Task WriteAsync(IChannelHandlerContext context, object message) => context.WriteAsync(message);
[Skip]
public virtual void Flush(IChannelHandlerContext context) => context.Flush();
[Skip]
public virtual Task BindAsync(IChannelHandlerContext context, EndPoint localAddress) => context.BindAsync(localAddress);
[Skip]
public virtual Task ConnectAsync(IChannelHandlerContext context, EndPoint remoteAddress, EndPoint localAddress) => context.ConnectAsync(remoteAddress, localAddress);
[Skip]
public virtual Task DisconnectAsync(IChannelHandlerContext context) => context.DisconnectAsync();
[Skip]
public virtual Task CloseAsync(IChannelHandlerContext context) => context.CloseAsync();
[Skip]
public virtual void ExceptionCaught(IChannelHandlerContext context, Exception exception) => context.FireExceptionCaught(exception);
[Skip]
public virtual Task DeregisterAsync(IChannelHandlerContext context) => context.DeregisterAsync();
[Skip]
public virtual void Read(IChannelHandlerContext context) => context.Read();
public virtual bool IsSharable => false;
protected void EnsureNotSharable()
{
if (this.IsSharable)
{
throw new InvalidOperationException($"ChannelHandler {StringUtil.SimpleClassName(this)} is not allowed to be shared");
}
}
}
}