Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
guo450212436
et
提交
58714eb1
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,体验更适合开发者的 AI 搜索 >>
提交
58714eb1
编写于
11月 20, 2017
作者:
T
tanghai
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
增加actorproxy回收机制,每分钟扫描过期5分钟的actorproxy
上级
af9e11aa
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
57 addition
and
5 deletion
+57
-5
Server/Model/Component/ActorProxyComponent.cs
Server/Model/Component/ActorProxyComponent.cs
+50
-4
Server/Model/Entity/ActorProxy.cs
Server/Model/Entity/ActorProxy.cs
+6
-0
Unity/Assets/Res/Config/GlobalProto.txt
Unity/Assets/Res/Config/GlobalProto.txt
+1
-1
未找到文件。
Server/Model/Component/ActorProxyComponent.cs
浏览文件 @
58714eb1
...
...
@@ -2,26 +2,72 @@
namespace
Model
{
[
ObjectEvent
]
public
class
ActorProxyComponentEvent
:
ObjectEvent
<
ActorProxyComponent
>,
IStart
{
// 每分钟扫描一次过期的actorproxy进行回收,过期时间是5分钟
public
async
void
Start
()
{
ActorProxyComponent
self
=
this
.
Get
();
List
<
long
>
timeoutActorProxyIds
=
new
List
<
long
>();
while
(
true
)
{
await
Game
.
Scene
.
GetComponent
<
TimerComponent
>().
WaitAsync
(
60000
);
if
(
self
.
Id
==
0
)
{
return
;
}
timeoutActorProxyIds
.
Clear
();
long
timeNow
=
TimeHelper
.
Now
();
foreach
(
long
id
in
self
.
ActorProxys
.
Keys
)
{
ActorProxy
actorProxy
=
self
.
Get
(
id
);
if
(
actorProxy
==
null
)
{
continue
;
}
if
(
timeNow
<
actorProxy
.
LastSendTime
+
5
*
60000
)
{
continue
;
}
timeoutActorProxyIds
.
Add
(
id
);
}
foreach
(
long
id
in
timeoutActorProxyIds
)
{
self
.
Remove
(
id
);
}
}
}
}
public
class
ActorProxyComponent
:
Component
{
p
rivate
readonly
Dictionary
<
long
,
ActorProxy
>
dictionary
=
new
Dictionary
<
long
,
ActorProxy
>();
p
ublic
readonly
Dictionary
<
long
,
ActorProxy
>
ActorProxys
=
new
Dictionary
<
long
,
ActorProxy
>();
public
ActorProxy
Get
(
long
id
)
{
if
(
this
.
dictionary
.
TryGetValue
(
id
,
out
ActorProxy
actorProxy
))
if
(
this
.
ActorProxys
.
TryGetValue
(
id
,
out
ActorProxy
actorProxy
))
{
return
actorProxy
;
}
actorProxy
=
EntityFactory
.
CreateWithId
<
ActorProxy
>(
id
);
this
.
dictionary
[
id
]
=
actorProxy
;
this
.
ActorProxys
[
id
]
=
actorProxy
;
return
actorProxy
;
}
public
void
Remove
(
long
id
)
{
ActorProxy
actorProxy
;
if
(!
this
.
dictionary
.
TryGetValue
(
id
,
out
actorProxy
))
if
(!
this
.
ActorProxys
.
TryGetValue
(
id
,
out
actorProxy
))
{
return
;
}
...
...
Server/Model/Entity/ActorProxy.cs
浏览文件 @
58714eb1
...
...
@@ -105,6 +105,9 @@ namespace Model
// 最大窗口
public
const
int
MaxWindowSize
=
1
;
// 最近发送消息的时间
public
long
LastSendTime
;
private
TaskCompletionSource
<
ActorTask
>
tcs
;
public
CancellationTokenSource
CancellationTokenSource
;
...
...
@@ -113,6 +116,7 @@ namespace Model
public
void
Awake
()
{
this
.
LastSendTime
=
TimeHelper
.
Now
();
this
.
RunningTasks
=
new
EQueue
<
ActorTask
>();
this
.
WaitingTasks
=
new
EQueue
<
ActorTask
>();
this
.
WindowSize
=
1
;
...
...
@@ -254,12 +258,14 @@ namespace Model
public
void
Send
(
AMessage
message
)
{
this
.
LastSendTime
=
TimeHelper
.
Now
();
ActorMessageTask
task
=
new
ActorMessageTask
(
this
,
message
);
this
.
Add
(
task
);
}
public
Task
<
Response
>
Call
<
Response
>(
ARequest
request
)
where
Response
:
AResponse
{
this
.
LastSendTime
=
TimeHelper
.
Now
();
ActorRpcTask
<
Response
>
task
=
new
ActorRpcTask
<
Response
>(
this
,
request
);
this
.
Add
(
task
);
return
task
.
Tcs
.
Task
;
...
...
Unity/Assets/Res/Config/GlobalProto.txt
浏览文件 @
58714eb1
{ "_t" : "GlobalProto", "AssetBundleServerUrl" : "http://172.16.20.27:8080/", "Address" : "172.16.20.27:10002" }
\ No newline at end of file
{ "_t" : "GlobalProto", "AssetBundleServerUrl" : "http://127.0.0.1:8080/", "Address" : "127.0.0.1:10002" }
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录