forked from egametang/ET
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAMHandler.cs
More file actions
38 lines (32 loc) · 905 Bytes
/
Copy pathAMHandler.cs
File metadata and controls
38 lines (32 loc) · 905 Bytes
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
using System;
namespace ET
{
[MessageHandler]
public abstract class AMHandler<Message>: IMHandler where Message : class
{
protected abstract ETVoid Run(Session session, Message message);
public void Handle(Session session, object msg)
{
Message message = msg as Message;
if (message == null)
{
Log.Error($"消息类型转换错误: {msg.GetType().Name} to {typeof (Message).Name}");
return;
}
if (session.IsDisposed)
{
Log.Error($"session disconnect {msg}");
return;
}
this.Run(session, message).Coroutine();
}
public Type GetMessageType()
{
return typeof (Message);
}
public Type GetResponseType()
{
return null;
}
}
}