Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
老鱼er
et
提交
307c290b
E
et
项目概览
老鱼er
/
et
与 Fork 源项目一致
从无法访问的项目Fork
通知
10
Star
1
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 搜索 >>
提交
307c290b
编写于
9月 04, 2017
作者:
T
tanghai
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
修复actor消息模型一个大bug
上级
2b3b655b
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
52 addition
and
34 deletion
+52
-34
Server/Model/Component/ActorMessageDispatherComponent.cs
Server/Model/Component/ActorMessageDispatherComponent.cs
+1
-6
Server/Model/Component/LocationComponent.cs
Server/Model/Component/LocationComponent.cs
+1
-1
Server/Model/Entity/ActorProxy.cs
Server/Model/Entity/ActorProxy.cs
+26
-11
Server/Model/Message/AMActorHandler.cs
Server/Model/Message/AMActorHandler.cs
+21
-8
Server/Model/Message/IMActorHandler.cs
Server/Model/Message/IMActorHandler.cs
+1
-1
Unity/Hotfix/UI/UILogin/Component/UILoginComponent.cs
Unity/Hotfix/UI/UILogin/Component/UILoginComponent.cs
+1
-1
Unity/Unity.sln
Unity/Unity.sln
+1
-6
未找到文件。
Server/Model/Component/ActorMessageDispatherComponent.cs
浏览文件 @
307c290b
...
...
@@ -80,12 +80,7 @@ namespace Model
return
false
;
}
if
(
message
.
AMessage
is
ARequest
request
)
{
request
.
RpcId
=
message
.
RpcId
;
}
return
await
handler
.
Handle
(
session
,
entity
,
message
.
AMessage
);
return
await
handler
.
Handle
(
session
,
entity
,
message
);
}
public
override
void
Dispose
()
...
...
Server/Model/Component/LocationComponent.cs
浏览文件 @
307c290b
...
...
@@ -198,8 +198,8 @@ namespace Model
{
if
(!
this
.
lockDict
.
ContainsKey
(
key
))
{
Log
.
Info
(
$"location get key:
{
key
}
"
);
this
.
locations
.
TryGetValue
(
key
,
out
int
location
);
Log
.
Info
(
$"location get key:
{
key
}
{
location
}
"
);
return
Task
.
FromResult
(
location
);
}
...
...
Server/Model/Entity/ActorProxy.cs
浏览文件 @
307c290b
...
...
@@ -2,11 +2,18 @@
using
System.Collections.Generic
;
using
System.Threading
;
using
System.Threading.Tasks
;
using
MongoDB.Bson.Serialization.Attributes
;
namespace
Model
{
public
abstract
class
ActorTask
{
[
BsonIgnore
]
public
ActorProxy
proxy
;
[
BsonElement
]
public
AMessage
message
;
public
abstract
Task
<
AResponse
>
Run
();
public
abstract
void
RunFail
(
int
error
);
...
...
@@ -17,9 +24,6 @@ namespace Model
/// </summary>
public
class
ActorMessageTask
:
ActorTask
{
private
readonly
ActorProxy
proxy
;
private
readonly
AMessage
message
;
public
ActorMessageTask
(
ActorProxy
proxy
,
AMessage
message
)
{
this
.
proxy
=
proxy
;
...
...
@@ -44,9 +48,7 @@ namespace Model
/// <typeparam name="Response"></typeparam>
public
class
ActorRpcTask
<
Response
>
:
ActorTask
where
Response
:
AResponse
{
private
readonly
ActorProxy
proxy
;
private
readonly
ARequest
message
;
[
BsonIgnore
]
public
readonly
TaskCompletionSource
<
Response
>
Tcs
=
new
TaskCompletionSource
<
Response
>();
public
ActorRpcTask
(
ActorProxy
proxy
,
ARequest
message
)
...
...
@@ -102,7 +104,7 @@ namespace Model
public
int
WindowSize
=
1
;
// 最大窗口
public
const
int
MaxWindowSize
=
1
00
;
public
const
int
MaxWindowSize
=
1
;
private
TaskCompletionSource
<
ActorTask
>
tcs
;
...
...
@@ -131,7 +133,7 @@ namespace Model
private
void
Remove
()
{
this
.
RunningTasks
.
Dequeue
();
ActorTask
task
=
this
.
RunningTasks
.
Dequeue
();
this
.
AllowGet
();
}
...
...
@@ -142,10 +144,12 @@ namespace Model
return
;
}
var
t
=
this
.
tcs
;
this
.
tcs
=
null
;
ActorTask
task
=
this
.
WaitingTasks
.
Dequeue
();
this
.
RunningTasks
.
Enqueue
(
task
);
var
t
=
this
.
tcs
;
this
.
tcs
=
null
;
t
.
SetResult
(
task
);
}
...
...
@@ -157,7 +161,7 @@ namespace Model
this
.
RunningTasks
.
Enqueue
(
task
);
return
Task
.
FromResult
(
task
);
}
this
.
tcs
=
new
TaskCompletionSource
<
ActorTask
>();
return
this
.
tcs
.
Task
;
}
...
...
@@ -247,6 +251,7 @@ namespace Model
{
try
{
//Log.Debug($"realcall {MongoHelper.ToJson(request)} {this.Address}");
request
.
Id
=
this
.
Id
;
Session
session
=
Game
.
Scene
.
GetComponent
<
NetInnerComponent
>().
Get
(
this
.
Address
);
Response
response
=
await
session
.
Call
<
Response
>(
request
,
cancellationToken
);
...
...
@@ -259,6 +264,16 @@ namespace Model
}
}
public
string
DebugQueue
(
Queue
<
ActorTask
>
tasks
)
{
string
s
=
""
;
foreach
(
ActorTask
task
in
tasks
)
{
s
+=
$"
{
task
.
message
.
GetType
().
Name
}
"
;
}
return
s
;
}
public
override
void
Dispose
()
{
if
(
this
.
Id
==
0
)
...
...
Server/Model/Message/AMActorHandler.cs
浏览文件 @
307c290b
...
...
@@ -7,12 +7,12 @@ namespace Model
{
protected
abstract
Task
<
bool
>
Run
(
E
entity
,
Message
message
);
public
async
Task
<
bool
>
Handle
(
Session
session
,
Entity
entity
,
A
Message
msg
)
public
async
Task
<
bool
>
Handle
(
Session
session
,
Entity
entity
,
A
ctorRequest
message
)
{
Message
m
essage
=
msg
as
Message
;
if
(
m
essage
==
null
)
Message
m
sg
=
message
.
AMessage
as
Message
;
if
(
m
sg
==
null
)
{
Log
.
Error
(
$"消息类型转换错误:
{
m
sg
.
GetType
().
FullName
}
to
{
typeof
(
Message
).
Name
}
"
);
Log
.
Error
(
$"消息类型转换错误:
{
m
essage
.
GetType
().
FullName
}
to
{
typeof
(
Message
).
Name
}
"
);
return
false
;
}
E
e
=
entity
as
E
;
...
...
@@ -21,7 +21,20 @@ namespace Model
Log
.
Error
(
$"Actor类型转换错误:
{
entity
.
GetType
().
Name
}
to
{
typeof
(
E
).
Name
}
"
);
return
false
;
}
return
await
this
.
Run
(
e
,
message
);
await
this
.
Run
(
e
,
msg
);
// 等回调回来,session可以已经断开了,所以需要判断session id是否为0
if
(
session
.
Id
==
0
)
{
return
false
;
}
ActorResponse
response
=
new
ActorResponse
{
RpcId
=
message
.
RpcId
};
session
.
Reply
(
response
);
return
true
;
}
public
Type
GetMessageType
()
...
...
@@ -42,11 +55,11 @@ namespace Model
protected
abstract
Task
<
bool
>
Run
(
E
entity
,
Request
message
,
Action
<
Response
>
reply
);
public
async
Task
<
bool
>
Handle
(
Session
session
,
Entity
entity
,
A
Message
message
)
public
async
Task
<
bool
>
Handle
(
Session
session
,
Entity
entity
,
A
ctorRequest
message
)
{
try
{
Request
request
=
message
as
Request
;
Request
request
=
message
.
AMessage
as
Request
;
if
(
request
==
null
)
{
Log
.
Error
(
$"消息类型转换错误:
{
message
.
GetType
().
FullName
}
to
{
typeof
(
Request
).
Name
}
"
);
...
...
@@ -65,7 +78,7 @@ namespace Model
{
return
;
}
response
.
RpcId
=
request
.
RpcId
;
response
.
RpcId
=
message
.
RpcId
;
session
.
Reply
(
response
);
});
}
...
...
Server/Model/Message/IMActorHandler.cs
浏览文件 @
307c290b
...
...
@@ -5,7 +5,7 @@ namespace Model
{
public
interface
IMActorHandler
{
Task
<
bool
>
Handle
(
Session
session
,
Entity
entity
,
A
Message
message
);
Task
<
bool
>
Handle
(
Session
session
,
Entity
entity
,
A
ctorRequest
message
);
Type
GetMessageType
();
}
}
\ No newline at end of file
Unity/Hotfix/UI/UILogin/Component/UILoginComponent.cs
浏览文件 @
307c290b
...
...
@@ -39,7 +39,7 @@ namespace Hotfix
Session
gateSession
=
Hotfix
.
Scene
.
ModelScene
.
GetComponent
<
NetOuterComponent
>().
Create
(
r2CLogin
.
Address
);
G2C_LoginGate
g2CLoginGate
=
await
gateSession
.
Call
<
G2C_LoginGate
>(
new
C2G_LoginGate
(
r2CLogin
.
Key
));
Log
.
Debug
(
$"
{
JsonHelper
.
ToJson
(
g2CLoginGate
)}
"
);
//
Log.Debug($"{JsonHelper.ToJson(g2CLoginGate)}");
Log
.
Info
(
"登陆gate成功!"
);
...
...
Unity/Unity.sln
浏览文件 @
307c290b
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26730.10
MinimumVisualStudioVersion = 10.0.40219.1
# Visual Studio 2017
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Unity.Plugins", "Unity.Plugins.csproj", "{D1FDB199-0FB7-099D-3771-C6A942E4E326}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Unity", "Unity.csproj", "{CF118143-7E37-744F-BE45-3F55345FEC40}"
...
...
@@ -37,7 +35,4 @@ Global
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {F4CA14D3-C715-499C-A877-DF4AB6A05C1E}
EndGlobalSection
EndGlobal
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录