Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
guo450212436
et
提交
f00711e9
E
et
项目概览
guo450212436
/
et
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
E
et
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
f00711e9
编写于
10月 30, 2017
作者:
T
tanghai
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
opcode使用枚举类型
上级
2a0a7c14
变更
19
显示空白变更内容
内联
并排
Showing
19 changed file
with
107 addition
and
138 deletion
+107
-138
Client-Server.sln.DotSettings.user
Client-Server.sln.DotSettings.user
+1
-0
Server/Hotfix/Other/InnerMessageDispatcher.cs
Server/Hotfix/Other/InnerMessageDispatcher.cs
+1
-1
Server/Hotfix/Other/OuterMessageDispatcher.cs
Server/Hotfix/Other/OuterMessageDispatcher.cs
+1
-1
Server/Model/Base/Message/MessageAttribute.cs
Server/Model/Base/Message/MessageAttribute.cs
+2
-2
Server/Model/Component/OpcodeTypeComponent.cs
Server/Model/Component/OpcodeTypeComponent.cs
+4
-4
Server/Model/Entity/Message/InnerOpcode.cs
Server/Model/Entity/Message/InnerOpcode.cs
+0
-49
Unity/Assets/Scripts/Base/Message/ClientDispatcher.cs
Unity/Assets/Scripts/Base/Message/ClientDispatcher.cs
+1
-1
Unity/Assets/Scripts/Base/Message/IMessageDispatcher.cs
Unity/Assets/Scripts/Base/Message/IMessageDispatcher.cs
+1
-1
Unity/Assets/Scripts/Base/Message/MessageAttribute.cs
Unity/Assets/Scripts/Base/Message/MessageAttribute.cs
+2
-2
Unity/Assets/Scripts/Base/Message/MessageInfo.cs
Unity/Assets/Scripts/Base/Message/MessageInfo.cs
+2
-2
Unity/Assets/Scripts/Component/ClientFrameComponent.cs
Unity/Assets/Scripts/Component/ClientFrameComponent.cs
+1
-1
Unity/Assets/Scripts/Component/MessageDispatherComponent.cs
Unity/Assets/Scripts/Component/MessageDispatherComponent.cs
+9
-37
Unity/Assets/Scripts/Component/OpcodeTypeComponent.cs
Unity/Assets/Scripts/Component/OpcodeTypeComponent.cs
+3
-3
Unity/Assets/Scripts/Entity/Message/Opcode.cs
Unity/Assets/Scripts/Entity/Message/Opcode.cs
+66
-18
Unity/Assets/Scripts/Entity/Message/OuterMessage.cs
Unity/Assets/Scripts/Entity/Message/OuterMessage.cs
+3
-7
Unity/Assets/Scripts/Entity/Session.cs
Unity/Assets/Scripts/Entity/Session.cs
+7
-6
Unity/Assets/Scripts/Handler/Actor_CreateUnitsHandler.cs
Unity/Assets/Scripts/Handler/Actor_CreateUnitsHandler.cs
+1
-1
Unity/Assets/Scripts/Handler/Actor_TestHandler.cs
Unity/Assets/Scripts/Handler/Actor_TestHandler.cs
+1
-1
Unity/Assets/Scripts/Handler/Frame_ClickMapHandler.cs
Unity/Assets/Scripts/Handler/Frame_ClickMapHandler.cs
+1
-1
未找到文件。
Client-Server.sln.DotSettings.user
浏览文件 @
f00711e9
...
...
@@ -6,6 +6,7 @@
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003APlayerComponent_002Ecs_002Fl_003AUnity_003FAssets_003FScripts_003FComponent_003FPlayerComponent_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003APlayerFactory_002Ecs_002Fl_003AUnity_003FAssets_003FScripts_003FFactory_003FPlayerFactory_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AUnitComponent_002Ecs_002Fl_003AUnity_003FAssets_003FScripts_003FComponent_003FUnitComponent_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/AnalysisEnabled/@EntryValue">VISIBLE_FILES</s:String>
<s:String x:Key="/Default/CodeStyle/CodeCleanup/Profiles/=Unity/@EntryIndexedValue"><?xml version="1.0" encoding="utf-16"?><Profile name="Unity"><CSArrangeThisQualifier>True</CSArrangeThisQualifier><CSRemoveCodeRedundancies>True</CSRemoveCodeRedundancies><CSMakeFieldReadonly>True</CSMakeFieldReadonly><CSUseVar><BehavourStyle>DISABLED</BehavourStyle><LocalVariableStyle>IMPLICIT_WHEN_INITIALIZER_HAS_TYPE</LocalVariableStyle><ForeachVariableStyle>IMPLICIT_EXCEPT_SIMPLE_TYPES</ForeachVariableStyle></CSUseVar><CSOptimizeUsings><OptimizeUsings>True</OptimizeUsings><EmbraceInRegion>False</EmbraceInRegion><RegionName></RegionName></CSOptimizeUsings><CSShortenReferences>True</CSShortenReferences><CSReformatCode>True</CSReformatCode><CSMakeAutoPropertyGetOnly>True</CSMakeAutoPropertyGetOnly><CSUseAutoProperty>True</CSUseAutoProperty><RemoveCodeRedundancies>True</RemoveCodeRedundancies><CSCodeStyleAttributes ArrangeTypeAccessModifier="True" ArrangeTypeMemberAccessModifier="True" SortModifiers="True" RemoveRedundantParentheses="True" AddMissingParentheses="True" ArrangeBraces="True" ArrangeAttributes="True" ArrangeArgumentsStyle="True" ArrangeCodeBodyStyle="True" /></Profile></s:String>
<s:String x:Key="/Default/Housekeeping/Layout/DialogWindows/RefactoringWizardWindow/Location/@EntryValue">247,-4</s:String>
<s:Int64 x:Key="/Default/Environment/SearchAndNavigation/DefaultOccurrencesGroupingIndex/@EntryValue">0</s:Int64>
...
...
Server/Hotfix/Other/InnerMessageDispatcher.cs
浏览文件 @
f00711e9
...
...
@@ -5,7 +5,7 @@ namespace Hotfix
{
public
class
InnerMessageDispatcher
:
IMessageDispatcher
{
public
void
Dispatch
(
Session
session
,
ushort
opcode
,
int
offset
,
byte
[]
messageBytes
,
AMessage
message
)
public
void
Dispatch
(
Session
session
,
Opcode
opcode
,
int
offset
,
byte
[]
messageBytes
,
AMessage
message
)
{
// 收到actor rpc request
if
(
message
is
ActorRpcRequest
actorRpcRequest
)
...
...
Server/Hotfix/Other/OuterMessageDispatcher.cs
浏览文件 @
f00711e9
...
...
@@ -5,7 +5,7 @@ namespace Hotfix
{
public
class
OuterMessageDispatcher
:
IMessageDispatcher
{
public
async
void
Dispatch
(
Session
session
,
ushort
opcode
,
int
offset
,
byte
[]
messageBytes
,
AMessage
message
)
public
async
void
Dispatch
(
Session
session
,
Opcode
opcode
,
int
offset
,
byte
[]
messageBytes
,
AMessage
message
)
{
// gate session收到actor消息直接转发给actor自己去处理
if
(
message
is
AActorMessage
)
...
...
Server/Model/Base/Message/MessageAttribute.cs
浏览文件 @
f00711e9
...
...
@@ -4,9 +4,9 @@ namespace Model
{
public
class
MessageAttribute
:
Attribute
{
public
ushort
Opcode
{
get
;
private
s
et
;
}
public
Opcode
Opcode
{
g
et
;
}
public
MessageAttribute
(
ushort
opcode
)
public
MessageAttribute
(
Opcode
opcode
)
{
this
.
Opcode
=
opcode
;
}
...
...
Server/Model/Component/OpcodeTypeComponent.cs
浏览文件 @
f00711e9
...
...
@@ -19,7 +19,7 @@ namespace Model
public
class
OpcodeTypeComponent
:
Component
{
private
Dictionary
<
ushort
,
Type
>
opcodeType
{
get
;
set
;
}
private
Dictionary
<
Opcode
,
Type
>
opcodeType
{
get
;
set
;
}
private
Dictionary
<
Type
,
MessageAttribute
>
messageOpcode
{
get
;
set
;
}
public
void
Awake
()
...
...
@@ -29,7 +29,7 @@ namespace Model
public
void
Load
()
{
this
.
opcodeType
=
new
Dictionary
<
ushort
,
Type
>();
this
.
opcodeType
=
new
Dictionary
<
Opcode
,
Type
>();
this
.
messageOpcode
=
new
Dictionary
<
Type
,
MessageAttribute
>();
Type
[]
types
=
DllHelper
.
GetMonoTypes
();
...
...
@@ -47,7 +47,7 @@ namespace Model
}
}
public
ushort
GetOpcode
(
Type
type
)
public
Opcode
GetOpcode
(
Type
type
)
{
if
(!
this
.
messageOpcode
.
TryGetValue
(
type
,
out
MessageAttribute
messageAttribute
))
{
...
...
@@ -56,7 +56,7 @@ namespace Model
return
messageAttribute
.
Opcode
;
}
public
Type
GetType
(
ushort
opcode
)
public
Type
GetType
(
Opcode
opcode
)
{
if
(!
this
.
opcodeType
.
TryGetValue
(
opcode
,
out
Type
messageType
))
{
...
...
Server/Model/Entity/Message/InnerOpcode.cs
已删除
100644 → 0
浏览文件 @
2a0a7c14
namespace
Model
{
// 1-999
public
static
partial
class
Opcode
{
public
const
ushort
ActorRequest
=
1
;
public
const
ushort
ActorResponse
=
2
;
public
const
ushort
ActorRpcRequest
=
3
;
public
const
ushort
ActorRpcResponse
=
4
;
public
const
ushort
G2G_LockRequest
=
10
;
public
const
ushort
G2G_LockResponse
=
11
;
public
const
ushort
G2G_LockReleaseRequest
=
12
;
public
const
ushort
G2G_LockReleaseResponse
=
13
;
public
const
ushort
M2A_Reload
=
20
;
public
const
ushort
A2M_Reload
=
21
;
public
const
ushort
DBSaveRequest
=
26
;
public
const
ushort
DBSaveResponse
=
27
;
public
const
ushort
DBQueryRequest
=
28
;
public
const
ushort
DBQueryResponse
=
29
;
public
const
ushort
DBSaveBatchResponse
=
37
;
public
const
ushort
DBSaveBatchRequest
=
38
;
public
const
ushort
DBQueryBatchRequest
=
61
;
public
const
ushort
DBQueryBatchResponse
=
62
;
public
const
ushort
DBQueryJsonRequest
=
65
;
public
const
ushort
DBQueryJsonResponse
=
66
;
public
const
ushort
ObjectAddRequest
=
70
;
public
const
ushort
ObjectAddResponse
=
71
;
public
const
ushort
ObjectRemoveRequest
=
72
;
public
const
ushort
ObjectRemoveResponse
=
73
;
public
const
ushort
ObjectLockRequest
=
74
;
public
const
ushort
ObjectLockResponse
=
75
;
public
const
ushort
ObjectUnLockRequest
=
76
;
public
const
ushort
ObjectUnLockResponse
=
77
;
public
const
ushort
ObjectGetRequest
=
78
;
public
const
ushort
ObjectGetResponse
=
79
;
public
const
ushort
R2G_GetLoginKey
=
101
;
public
const
ushort
G2R_GetLoginKey
=
102
;
public
const
ushort
G2M_CreateUnit
=
103
;
public
const
ushort
M2G_CreateUnit
=
104
;
public
const
ushort
M2M_TrasferUnitRequest
=
105
;
public
const
ushort
M2M_TrasferUnitResponse
=
106
;
}
}
Unity/Assets/Scripts/Base/Message/ClientDispatcher.cs
浏览文件 @
f00711e9
...
...
@@ -4,7 +4,7 @@ namespace Model
{
public
class
ClientDispatcher
:
IMessageDispatcher
{
public
void
Dispatch
(
Session
session
,
ushort
opcode
,
int
offset
,
byte
[]
messageBytes
,
AMessage
message
)
public
void
Dispatch
(
Session
session
,
Opcode
opcode
,
int
offset
,
byte
[]
messageBytes
,
AMessage
message
)
{
// 如果是帧同步消息,交给ClientFrameComponent处理
FrameMessage
frameMessage
=
message
as
FrameMessage
;
...
...
Unity/Assets/Scripts/Base/Message/IMessageDispatcher.cs
浏览文件 @
f00711e9
...
...
@@ -2,6 +2,6 @@
{
public
interface
IMessageDispatcher
{
void
Dispatch
(
Session
session
,
ushort
opcode
,
int
offset
,
byte
[]
messageBytes
,
AMessage
message
);
void
Dispatch
(
Session
session
,
Opcode
opcode
,
int
offset
,
byte
[]
messageBytes
,
AMessage
message
);
}
}
Unity/Assets/Scripts/Base/Message/MessageAttribute.cs
浏览文件 @
f00711e9
...
...
@@ -4,9 +4,9 @@ namespace Model
{
public
class
MessageAttribute
:
Attribute
{
public
ushort
Opcode
{
get
;
private
s
et
;
}
public
Opcode
Opcode
{
g
et
;
}
public
MessageAttribute
(
ushort
opcode
)
public
MessageAttribute
(
Opcode
opcode
)
{
this
.
Opcode
=
opcode
;
}
...
...
Unity/Assets/Scripts/Base/Message/MessageInfo.cs
浏览文件 @
f00711e9
...
...
@@ -2,10 +2,10 @@
{
public
struct
MessageInfo
{
public
ushort
Opcode
{
get
;
set
;
}
public
Opcode
Opcode
{
get
;
set
;
}
public
AMessage
Message
{
get
;
set
;
}
public
MessageInfo
(
ushort
opcode
,
AMessage
message
)
public
MessageInfo
(
Opcode
opcode
,
AMessage
message
)
{
this
.
Opcode
=
opcode
;
this
.
Message
=
message
;
...
...
Unity/Assets/Scripts/Component/ClientFrameComponent.cs
浏览文件 @
f00711e9
...
...
@@ -71,7 +71,7 @@
for
(
int
i
=
0
;
i
<
frameMessage
.
Messages
.
Count
;
++
i
)
{
AFrameMessage
message
=
frameMessage
.
Messages
[
i
];
ushort
opcode
=
Game
.
Scene
.
GetComponent
<
OpcodeTypeComponent
>().
GetOpcode
(
message
.
GetType
());
Opcode
opcode
=
Game
.
Scene
.
GetComponent
<
OpcodeTypeComponent
>().
GetOpcode
(
message
.
GetType
());
Game
.
Scene
.
GetComponent
<
MessageDispatherComponent
>().
Handle
(
new
MessageInfo
()
{
Opcode
=
opcode
,
Message
=
message
});
}
}
...
...
Unity/Assets/Scripts/Component/MessageDispatherComponent.cs
浏览文件 @
f00711e9
...
...
@@ -67,40 +67,12 @@ namespace Model
}
}
public
static
class
Opcode2Name
{
private
static
Dictionary
<
int
,
string
>
_init
=
new
Dictionary
<
int
,
string
>();
public
static
string
GetName
(
int
code
)
{
if
(
_init
.
Count
==
0
)
{
Type
type
=
typeof
(
Opcode
);
FieldInfo
[]
fields
=
type
.
GetFields
(
BindingFlags
.
NonPublic
|
BindingFlags
.
Public
|
BindingFlags
.
Instance
|
BindingFlags
.
Static
);
foreach
(
FieldInfo
field
in
fields
)
{
if
(!
field
.
IsStatic
)
{
continue
;
}
int
codeID
=
(
ushort
)
field
.
GetValue
(
null
);
if
(
_init
.
ContainsKey
(
codeID
))
{
Log
.
Warning
(
$"重复的Opcode:
{
codeID
}
"
);
continue
;
}
_init
.
Add
(
codeID
,
field
.
Name
);
}
}
return
_init
[
code
];
}
}
/// <summary>
/// 消息分发组件
/// </summary>
public
class
MessageDispatherComponent
:
Component
{
private
Dictionary
<
ushort
,
List
<
IMessageMethod
>>
handlers
;
private
Dictionary
<
Opcode
,
List
<
IMessageMethod
>>
handlers
;
public
void
Awake
()
...
...
@@ -110,7 +82,7 @@ namespace Model
public
void
Load
()
{
handlers
=
new
Dictionary
<
ushort
,
List
<
IMessageMethod
>>();
handlers
=
new
Dictionary
<
Opcode
,
List
<
IMessageMethod
>>();
Type
[]
types
=
DllHelper
.
GetMonoTypes
();
...
...
@@ -123,11 +95,11 @@ namespace Model
}
MessageHandlerAttribute
messageHandlerAttribute
=
(
MessageHandlerAttribute
)
attrs
[
0
];
IMHandler
iMHandler
=
(
IMHandler
)
Activator
.
CreateInstance
(
type
);
if
(!
this
.
handlers
.
ContainsKey
(
messageHandlerAttribute
.
Opcode
))
if
(!
this
.
handlers
.
ContainsKey
(
(
Opcode
)
messageHandlerAttribute
.
Opcode
))
{
this
.
handlers
.
Add
(
messageHandlerAttribute
.
Opcode
,
new
List
<
IMessageMethod
>());
this
.
handlers
.
Add
(
(
Opcode
)
messageHandlerAttribute
.
Opcode
,
new
List
<
IMessageMethod
>());
}
this
.
handlers
[
messageHandlerAttribute
.
Opcode
].
Add
(
new
IMessageMonoMethod
(
iMHandler
));
this
.
handlers
[
(
Opcode
)
messageHandlerAttribute
.
Opcode
].
Add
(
new
IMessageMonoMethod
(
iMHandler
));
}
// hotfix dll
...
...
@@ -146,11 +118,11 @@ namespace Model
IMHandler
iMHandler
=
(
IMHandler
)
Activator
.
CreateInstance
(
type
);
IMessageMethod
iMessageMethod
=
new
IMessageMonoMethod
(
iMHandler
);
#endif
if
(!
this
.
handlers
.
ContainsKey
(
messageHandlerAttribute
.
Opcode
))
if
(!
this
.
handlers
.
ContainsKey
(
(
Opcode
)
messageHandlerAttribute
.
Opcode
))
{
this
.
handlers
.
Add
(
messageHandlerAttribute
.
Opcode
,
new
List
<
IMessageMethod
>());
this
.
handlers
.
Add
(
(
Opcode
)
messageHandlerAttribute
.
Opcode
,
new
List
<
IMessageMethod
>());
}
this
.
handlers
[
messageHandlerAttribute
.
Opcode
].
Add
(
iMessageMethod
);
this
.
handlers
[
(
Opcode
)
messageHandlerAttribute
.
Opcode
].
Add
(
iMessageMethod
);
}
}
...
...
@@ -159,7 +131,7 @@ namespace Model
List
<
IMessageMethod
>
actions
;
if
(!
this
.
handlers
.
TryGetValue
(
messageInfo
.
Opcode
,
out
actions
))
{
Log
.
Error
(
$"消息
{
Opcode2Name
.
GetName
(
messageInfo
.
Opcode
)}
(
{
messageInfo
.
Opcode
}
)
没有处理"
);
Log
.
Error
(
$"消息
{
messageInfo
.
Opcode
}
没有处理"
);
return
;
}
...
...
Unity/Assets/Scripts/Component/OpcodeTypeComponent.cs
浏览文件 @
f00711e9
...
...
@@ -13,7 +13,7 @@ namespace Model
public
class
OpcodeTypeComponent
:
Component
{
private
readonly
DoubleMap
<
ushort
,
Type
>
opcodeTypes
=
new
DoubleMap
<
ushort
,
Type
>();
private
readonly
DoubleMap
<
Opcode
,
Type
>
opcodeTypes
=
new
DoubleMap
<
Opcode
,
Type
>();
public
void
Awake
()
{
...
...
@@ -36,12 +36,12 @@ namespace Model
}
}
public
ushort
GetOpcode
(
Type
type
)
public
Opcode
GetOpcode
(
Type
type
)
{
return
this
.
opcodeTypes
.
GetKeyByValue
(
type
);
}
public
Type
GetType
(
ushort
opcode
)
public
Type
GetType
(
Opcode
opcode
)
{
return
this
.
opcodeTypes
.
GetValueByKey
(
opcode
);
}
...
...
Unity/Assets/Scripts/Entity/Message/Opcode.cs
浏览文件 @
f00711e9
namespace
Model
{
// 1000开始
public
static
partial
class
Opcode
public
enum
Opcode
:
ushort
{
public
const
ushort
FrameMessage
=
1000
;
public
const
ushort
C2R_Login
=
1001
;
public
const
ushort
R2C_Login
=
1002
;
public
const
ushort
R2C_ServerLog
=
1003
;
public
const
ushort
C2G_LoginGate
=
1004
;
public
const
ushort
G2C_LoginGate
=
1005
;
public
const
ushort
C2G_EnterMap
=
1006
;
public
const
ushort
G2C_EnterMap
=
1007
;
public
const
ushort
C2M_Reload
=
1008
;
public
const
ushort
Actor_Test
=
2001
;
public
const
ushort
Actor_TestRequest
=
2002
;
public
const
ushort
Actor_TestResponse
=
2003
;
public
const
ushort
Actor_TransferRequest
=
2004
;
public
const
ushort
Actor_TransferResponse
=
2005
;
public
const
ushort
Frame_ClickMap
=
2006
;
public
const
ushort
Actor_CreateUnits
=
2007
;
FrameMessage
=
1000
,
C2R_Login
=
1001
,
R2C_Login
=
1002
,
R2C_ServerLog
=
1003
,
C2G_LoginGate
=
1004
,
G2C_LoginGate
=
1005
,
C2G_EnterMap
=
1006
,
G2C_EnterMap
=
1007
,
C2M_Reload
=
1008
,
M2C_Reload
=
1009
,
C2R_Ping
=
1010
,
R2C_Ping
=
1011
,
Actor_Test
=
2001
,
Actor_TestRequest
=
2002
,
Actor_TestResponse
=
2003
,
Actor_TransferRequest
=
2004
,
Actor_TransferResponse
=
2005
,
Frame_ClickMap
=
2006
,
Actor_CreateUnits
=
2007
,
// server inner opcode
ActorRequest
=
1
,
ActorResponse
=
2
,
ActorRpcRequest
=
3
,
ActorRpcResponse
=
4
,
G2G_LockRequest
=
10
,
G2G_LockResponse
=
11
,
G2G_LockReleaseRequest
=
12
,
G2G_LockReleaseResponse
=
13
,
M2A_Reload
=
20
,
A2M_Reload
=
21
,
DBSaveRequest
=
26
,
DBSaveResponse
=
27
,
DBQueryRequest
=
28
,
DBQueryResponse
=
29
,
DBSaveBatchResponse
=
37
,
DBSaveBatchRequest
=
38
,
DBQueryBatchRequest
=
61
,
DBQueryBatchResponse
=
62
,
DBQueryJsonRequest
=
65
,
DBQueryJsonResponse
=
66
,
ObjectAddRequest
=
70
,
ObjectAddResponse
=
71
,
ObjectRemoveRequest
=
72
,
ObjectRemoveResponse
=
73
,
ObjectLockRequest
=
74
,
ObjectLockResponse
=
75
,
ObjectUnLockRequest
=
76
,
ObjectUnLockResponse
=
77
,
ObjectGetRequest
=
78
,
ObjectGetResponse
=
79
,
R2G_GetLoginKey
=
101
,
G2R_GetLoginKey
=
102
,
G2M_CreateUnit
=
103
,
M2G_CreateUnit
=
104
,
M2M_TrasferUnitRequest
=
105
,
M2M_TrasferUnitResponse
=
106
,
}
}
Unity/Assets/Scripts/Entity/Message/OuterMessage.cs
浏览文件 @
f00711e9
// 服务器与客户端之间的消息 Opcode从1-9999
using
System.Collections.Generic
;
using
ProtoBuf
;
...
...
@@ -109,7 +107,6 @@ namespace Model
public
AMessage
Message
;
}
// 服务端发给客户端,每帧一条
[
Message
(
Opcode
.
FrameMessage
)]
public
class
FrameMessage
:
AActorMessage
{
...
...
@@ -117,7 +114,6 @@ namespace Model
public
List
<
AFrameMessage
>
Messages
=
new
List
<
AFrameMessage
>();
}
// 客户端点击地图
[
ProtoContract
]
[
Message
(
Opcode
.
Frame_ClickMap
)]
public
class
Frame_ClickMap
:
AFrameMessage
...
...
@@ -134,17 +130,17 @@ namespace Model
public
AppType
AppType
;
}
[
Message
(
11
)]
[
Message
(
Opcode
.
M2C_Reload
)]
public
class
M2C_Reload
:
AResponse
{
}
[
Message
(
14
)]
[
Message
(
Opcode
.
C2R_Ping
)]
public
class
C2R_Ping
:
ARequest
{
}
[
Message
(
15
)]
[
Message
(
Opcode
.
R2C_Ping
)]
public
class
R2C_Ping
:
AResponse
{
}
...
...
Unity/Assets/Scripts/Entity/Session.cs
浏览文件 @
f00711e9
...
...
@@ -97,7 +97,8 @@ namespace Model
private
void
RunDecompressedBytes
(
ushort
opcode
,
byte
[]
messageBytes
,
int
offset
)
{
Type
messageType
=
this
.
network
.
Entity
.
GetComponent
<
OpcodeTypeComponent
>().
GetType
(
opcode
);
Opcode
op
=
(
Opcode
)
opcode
;
Type
messageType
=
this
.
network
.
Entity
.
GetComponent
<
OpcodeTypeComponent
>().
GetType
(
op
);
object
message
=
this
.
network
.
MessagePacker
.
DeserializeFrom
(
messageType
,
messageBytes
,
offset
,
messageBytes
.
Length
-
offset
);
//Log.Debug($"recv: {MongoHelper.ToJson(message)}");
...
...
@@ -117,7 +118,7 @@ namespace Model
return
;
}
this
.
network
.
MessageDispatcher
.
Dispatch
(
this
,
op
code
,
offset
,
messageBytes
,
(
AMessage
)
message
);
this
.
network
.
MessageDispatcher
.
Dispatch
(
this
,
op
,
offset
,
messageBytes
,
(
AMessage
)
message
);
}
/// <summary>
...
...
@@ -207,8 +208,8 @@ namespace Model
private
void
SendMessage
(
object
message
)
{
//Log.Debug($"send: {MongoHelper.ToJson(message)}");
ushort
opcode
=
this
.
network
.
Entity
.
GetComponent
<
OpcodeTypeComponent
>().
GetOpcode
(
message
.
GetType
());
Opcode
opcode
=
this
.
network
.
Entity
.
GetComponent
<
OpcodeTypeComponent
>().
GetOpcode
(
message
.
GetType
());
ushort
op
=
(
ushort
)
opcode
;
byte
[]
messageBytes
=
this
.
network
.
MessagePacker
.
SerializeToByteArray
(
message
);
if
(
messageBytes
.
Length
>
100
)
{
...
...
@@ -216,11 +217,11 @@ namespace Model
if
(
newMessageBytes
.
Length
<
messageBytes
.
Length
)
{
messageBytes
=
newMessageBytes
;
op
code
|=
0x8000
;
op
|=
0x8000
;
}
}
byte
[]
opcodeBytes
=
BitConverter
.
GetBytes
(
op
code
);
byte
[]
opcodeBytes
=
BitConverter
.
GetBytes
(
op
);
this
.
byteses
[
0
]
=
opcodeBytes
;
this
.
byteses
[
1
]
=
messageBytes
;
...
...
Unity/Assets/Scripts/Handler/Actor_CreateUnitsHandler.cs
浏览文件 @
f00711e9
...
...
@@ -2,7 +2,7 @@
namespace
Model
{
[
MessageHandler
(
Opcode
.
Actor_CreateUnits
)]
[
MessageHandler
(
(
int
)
Opcode
.
Actor_CreateUnits
)]
public
class
Actor_CreateUnitsHandler
:
AMHandler
<
Actor_CreateUnits
>
{
protected
override
void
Run
(
Actor_CreateUnits
message
)
...
...
Unity/Assets/Scripts/Handler/Actor_TestHandler.cs
浏览文件 @
f00711e9
namespace
Model
{
[
MessageHandler
(
Opcode
.
Actor_Test
)]
[
MessageHandler
(
(
int
)
Opcode
.
Actor_Test
)]
public
class
Actor_TestHandler
:
AMHandler
<
Actor_Test
>
{
protected
override
void
Run
(
Actor_Test
message
)
...
...
Unity/Assets/Scripts/Handler/Frame_ClickMapHandler.cs
浏览文件 @
f00711e9
...
...
@@ -2,7 +2,7 @@
namespace
Model
{
[
MessageHandler
(
Opcode
.
Frame_ClickMap
)]
[
MessageHandler
(
(
int
)
Opcode
.
Frame_ClickMap
)]
public
class
Frame_ClickMapHandler
:
AMHandler
<
Frame_ClickMap
>
{
protected
override
void
Run
(
Frame_ClickMap
message
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录