Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
guo450212436
et
提交
093b0b60
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,发现更多精彩内容 >>
提交
093b0b60
编写于
3月 30, 2015
作者:
T
tanghai
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
1.gate收到消息加上id转发给logic server.
2.logic server收到client消息交给相应的unit actor执行,其余的消息进行分发处理
上级
c1bada1b
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
91 addition
and
20 deletion
+91
-20
CSharp/Game/Controller/AddressHelper.cs
CSharp/Game/Controller/AddressHelper.cs
+15
-0
CSharp/Game/Controller/ConfigCategory/BuffCategory.cs
CSharp/Game/Controller/ConfigCategory/BuffCategory.cs
+1
-1
CSharp/Game/Controller/Controller.csproj
CSharp/Game/Controller/Controller.csproj
+3
-0
CSharp/Game/Controller/Event/GateMessageEvent.cs
CSharp/Game/Controller/Event/GateMessageEvent.cs
+32
-0
CSharp/Game/Controller/Event/LogicMessageEvent.cs
CSharp/Game/Controller/Event/LogicMessageEvent.cs
+33
-0
CSharp/Game/Model/Component/GateNetworkComponent.cs
CSharp/Game/Model/Component/GateNetworkComponent.cs
+1
-13
CSharp/Game/Model/Component/NetworkComponent.cs
CSharp/Game/Model/Component/NetworkComponent.cs
+6
-6
未找到文件。
CSharp/Game/Controller/AddressHelper.cs
0 → 100644
浏览文件 @
093b0b60
using
Model
;
namespace
Controller
{
public
static
class
AddressHelper
{
public
static
string
GetAddressByServerName
(
string
serverName
)
{
ServerInfoConfig
serverInfoConfig
=
World
.
Instance
.
GetComponent
<
ConfigComponent
>()
.
GetCategory
<
ServerInfoCategory
>()[
serverName
];
string
address
=
serverInfoConfig
.
Host
+
":"
+
serverInfoConfig
.
Port
;
return
address
;
}
}
}
CSharp/Game/Controller/ConfigCategory/BuffCategory.cs
浏览文件 @
093b0b60
...
...
@@ -2,7 +2,7 @@
namespace
Controller
{
[
Config
(
ServerType
.
Realm
|
ServerType
.
Gate
|
ServerType
.
City
)]
[
Config
(
ServerType
.
City
)]
public
class
BuffCategory
:
ACategory
<
BuffConfig
>
{
}
...
...
CSharp/Game/Controller/Controller.csproj
浏览文件 @
093b0b60
...
...
@@ -38,6 +38,7 @@
<Reference
Include=
"System.Core"
/>
</ItemGroup>
<ItemGroup>
<Compile
Include=
"AddressHelper.cs"
/>
<Compile
Include=
"Event\BuffTimeoutEvent.cs"
/>
<Compile
Include=
"BehaviorTreeNode\Not.cs"
/>
<Compile
Include=
"BehaviorTreeNode\Selector.cs"
/>
...
...
@@ -47,6 +48,8 @@
<Compile
Include=
"ConfigCategory\NodeCategory.cs"
/>
<Compile
Include=
"ConfigCategory\ServerInfoCategory.cs"
/>
<Compile
Include=
"ConfigCategory\UnitCategory.cs"
/>
<Compile
Include=
"Event\LogicMessageEvent.cs"
/>
<Compile
Include=
"Event\GateMessageEvent.cs"
/>
<Compile
Include=
"Factory\UnitFactory.cs"
/>
<Compile
Include=
"Message\CMsgLoginEvent.cs"
/>
<Compile
Include=
"NodeType.cs"
/>
...
...
CSharp/Game/Controller/Event/GateMessageEvent.cs
0 → 100644
浏览文件 @
093b0b60
using
System
;
using
Common.Network
;
using
Model
;
namespace
Controller
{
[
Event
(
EventType
.
GateMessage
,
ServerType
.
Gate
)]
public
class
GateMessageEvent
:
IEventSync
{
public
void
Run
(
Env
env
)
{
byte
[]
message
=
env
.
Get
<
byte
[
]>
(
EnvKey
.
Message
);
AChannel
channel
=
env
.
Get
<
AChannel
>(
EnvKey
.
Channel
);
// 进行消息分发
int
opcode
=
BitConverter
.
ToUInt16
(
message
,
0
);
if
(!
MessageTypeHelper
.
IsClientMessage
(
opcode
))
{
return
;
}
ChannelUnitInfoComponent
channelUnitInfoComponent
=
channel
.
GetComponent
<
ChannelUnitInfoComponent
>();
byte
[]
idBuffer
=
channelUnitInfoComponent
.
PlayerId
.
ToByteArray
();
byte
[]
buffer
=
new
byte
[
message
.
Length
+
12
];
Array
.
Copy
(
message
,
0
,
buffer
,
0
,
4
);
Array
.
Copy
(
idBuffer
,
0
,
buffer
,
4
,
idBuffer
.
Length
);
Array
.
Copy
(
message
,
4
,
buffer
,
4
+
12
,
message
.
Length
-
4
);
string
address
=
AddressHelper
.
GetAddressByServerName
(
channelUnitInfoComponent
.
ServerName
);
World
.
Instance
.
GetComponent
<
NetworkComponent
>().
SendAsync
(
address
,
buffer
);
}
}
}
CSharp/Game/Controller/Event/LogicMessageEvent.cs
0 → 100644
浏览文件 @
093b0b60
using
System
;
using
Model
;
using
MongoDB.Bson
;
namespace
Controller
{
[
Event
(
EventType
.
Message
,
ServerType
.
All
)]
public
class
LogicMessageEvent
:
IEventSync
{
public
void
Run
(
Env
env
)
{
byte
[]
message
=
env
.
Get
<
byte
[
]>
(
EnvKey
.
Message
);
int
opcode
=
BitConverter
.
ToUInt16
(
message
,
0
);
// 如果是客户端消息,转交给unit actor处理
// 逻辑服收到客户端消息opcode(2) + id(12) + content
if
(
MessageTypeHelper
.
IsClientMessage
(
opcode
))
{
byte
[]
idBuffer
=
new
byte
[
12
];
Array
.
Copy
(
message
,
2
,
idBuffer
,
0
,
12
);
ObjectId
unitId
=
new
ObjectId
(
idBuffer
);
Unit
unit
=
World
.
Instance
.
GetComponent
<
UnitComponent
>().
Get
(
unitId
);
if
(
unit
!=
null
)
{
unit
.
GetComponent
<
ActorComponent
>().
Add
(
env
);
}
return
;
}
World
.
Instance
.
GetComponent
<
EventComponent
<
MessageAttribute
>>().
RunAsync
(
opcode
,
env
);
}
}
}
CSharp/Game/Model/Component/GateNetworkComponent.cs
浏览文件 @
093b0b60
...
...
@@ -66,19 +66,7 @@ namespace Model
env
[
EnvKey
.
Channel
]
=
channel
;
env
[
EnvKey
.
Message
]
=
message
;
// 进行消息分发
int
opcode
=
BitConverter
.
ToUInt16
(
message
,
0
);
if
(!
MessageTypeHelper
.
IsClientMessage
(
opcode
))
{
ChannelUnitInfoComponent
channelUnitInfoComponent
=
channel
.
GetComponent
<
ChannelUnitInfoComponent
>();
byte
[]
idBuffer
=
channelUnitInfoComponent
.
PlayerId
.
ToByteArray
();
byte
[]
buffer
=
new
byte
[
message
.
Length
+
12
];
Array
.
Copy
(
message
,
0
,
buffer
,
0
,
4
);
Array
.
Copy
(
idBuffer
,
0
,
buffer
,
4
,
idBuffer
.
Length
);
Array
.
Copy
(
message
,
4
,
buffer
,
4
+
12
,
message
.
Length
-
4
);
continue
;
}
World
.
Instance
.
GetComponent
<
EventComponent
<
MessageAttribute
>>().
RunAsync
(
opcode
,
env
);
World
.
Instance
.
GetComponent
<
EventComponent
<
EventAttribute
>>().
Run
(
EventType
.
GateMessage
,
env
);
}
}
}
...
...
CSharp/Game/Model/Component/NetworkComponent.cs
浏览文件 @
093b0b60
...
...
@@ -72,11 +72,6 @@ namespace Model
env
[
EnvKey
.
Message
]
=
message
;
int
opcode
=
BitConverter
.
ToUInt16
(
message
,
0
);
if
(
MessageTypeHelper
.
IsClientMessage
(
opcode
))
{
continue
;
}
// 这个区间表示消息是rpc响应消息
if
(
MessageTypeHelper
.
IsRpcResponseMessage
(
opcode
))
{
...
...
@@ -86,10 +81,15 @@ namespace Model
}
// 进行消息分发
World
.
Instance
.
GetComponent
<
EventComponent
<
MessageAttribute
>>().
RunAsync
(
opcod
e
,
env
);
World
.
Instance
.
GetComponent
<
EventComponent
<
EventAttribute
>>().
Run
(
EventType
.
GateMessag
e
,
env
);
}
}
public
async
void
SendAsync
(
string
address
,
byte
[]
buffer
)
{
}
// 消息回调或者超时回调
public
void
RequestCallback
(
AChannel
channel
,
int
id
,
byte
[]
buffer
,
bool
isOK
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录