Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
guo450212436
et
提交
266eda7c
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,发现更多精彩内容 >>
提交
266eda7c
编写于
6月 14, 2018
作者:
T
tanghai
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
修复新TCP库的一个bug
上级
aee8ac6e
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
31 addition
and
50 deletion
+31
-50
Server/Hotfix/Handler/C2R_PingHandler.cs
Server/Hotfix/Handler/C2R_PingHandler.cs
+0
-21
Server/Model/Component/AppManagerComponent.cs
Server/Model/Component/AppManagerComponent.cs
+2
-0
Server/Model/Module/Actor/ActorMessageSenderComponent.cs
Server/Model/Module/Actor/ActorMessageSenderComponent.cs
+10
-1
Unity/Assets/Scripts/Base/Object/ComponentWithId.cs
Unity/Assets/Scripts/Base/Object/ComponentWithId.cs
+0
-1
Unity/Assets/Scripts/Module/Message/Network/TCP/TChannel.cs
Unity/Assets/Scripts/Module/Message/Network/TCP/TChannel.cs
+4
-3
Unity/Assets/Scripts/Module/Message/NetworkComponent.cs
Unity/Assets/Scripts/Module/Message/NetworkComponent.cs
+7
-2
Unity/Assets/Scripts/Module/Message/Session.cs
Unity/Assets/Scripts/Module/Message/Session.cs
+8
-21
Unity/Hotfix/Base/Object/ComponentWithId.cs
Unity/Hotfix/Base/Object/ComponentWithId.cs
+0
-1
未找到文件。
Server/Hotfix/Handler/C2R_PingHandler.cs
浏览文件 @
266eda7c
...
...
@@ -6,31 +6,10 @@ namespace ETHotfix
[
MessageHandler
(
AppType
.
AllServer
)]
public
class
C2R_PingHandler
:
AMRpcHandler
<
C2R_Ping
,
R2C_Ping
>
{
private
bool
isStart
=
false
;
protected
override
void
Run
(
Session
session
,
C2R_Ping
message
,
Action
<
R2C_Ping
>
reply
)
{
R2C_Ping
r2CPing
=
new
R2C_Ping
();
reply
(
r2CPing
);
if
(!
this
.
isStart
)
{
isStart
=
true
;
Start
(
session
);
}
}
public
async
void
Start
(
Session
session
)
{
TimerComponent
timerComponent
=
Game
.
Scene
.
GetComponent
<
TimerComponent
>();
G2C_Test
g2CTest
=
new
G2C_Test
();
while
(
true
)
{
await
timerComponent
.
WaitAsync
(
1
);
for
(
int
i
=
0
;
i
<
20
;
++
i
)
{
session
.
Send
(
g2CTest
);
}
}
}
}
}
\ No newline at end of file
Server/Model/Component/AppManagerComponent.cs
浏览文件 @
266eda7c
...
...
@@ -25,6 +25,8 @@ namespace ETModel
foreach
(
StartConfig
startConfig
in
startConfigs
)
{
Game
.
Scene
.
GetComponent
<
TimerComponent
>().
WaitAsync
(
100
);
if
(!
ips
.
Contains
(
startConfig
.
ServerIP
)
&&
startConfig
.
ServerIP
!=
"*"
)
{
continue
;
...
...
Server/Model/Module/Actor/ActorMessageSenderComponent.cs
浏览文件 @
266eda7c
using
System.Collections.Generic
;
using
System
;
using
System.Collections.Generic
;
namespace
ETModel
{
...
...
@@ -22,6 +23,10 @@ namespace ETModel
public
ActorMessageSender
Get
(
long
id
)
{
if
(
id
==
0
)
{
throw
new
Exception
(
$"actor id is 0"
);
}
if
(
this
.
ActorMessageSenders
.
TryGetValue
(
id
,
out
ActorMessageSender
actorMessageSender
))
{
return
actorMessageSender
;
...
...
@@ -35,6 +40,10 @@ namespace ETModel
public
ActorMessageSender
GetWithActorId
(
long
actorId
)
{
if
(
actorId
==
0
)
{
throw
new
Exception
(
$"actor id is 0"
);
}
if
(
this
.
ActorMessageSenders
.
TryGetValue
(
actorId
,
out
ActorMessageSender
actorMessageSender
))
{
return
actorMessageSender
;
...
...
Unity/Assets/Scripts/Base/Object/ComponentWithId.cs
浏览文件 @
266eda7c
...
...
@@ -14,7 +14,6 @@ namespace ETModel
protected
ComponentWithId
()
{
this
.
Id
=
this
.
InstanceId
;
}
protected
ComponentWithId
(
long
id
)
...
...
Unity/Assets/Scripts/Module/Message/Network/TCP/TChannel.cs
浏览文件 @
266eda7c
...
...
@@ -74,9 +74,8 @@ namespace ETModel
this
.
ConnectAsync
(
this
.
RemoteAddress
);
return
;
}
this
.
StartSend
();
this
.
StartRecv
();
this
.
StartSend
();
}
public
override
void
Send
(
byte
[]
buffer
,
int
index
,
int
length
)
...
...
@@ -158,10 +157,12 @@ namespace ETModel
this
.
OnError
((
int
)
e
.
SocketError
);
return
;
}
e
.
RemoteEndPoint
=
null
;
this
.
isConnected
=
true
;
this
.
StartSend
();
this
.
StartRecv
();
this
.
StartSend
();
}
private
void
OnDisconnectComplete
(
object
o
)
...
...
Unity/Assets/Scripts/Module/Message/NetworkComponent.cs
浏览文件 @
266eda7c
...
...
@@ -70,9 +70,14 @@ namespace ETModel
this
.
Service
.
Start
();
}
public
int
Count
{
get
{
return
this
.
sessions
.
Count
;
}
}
public
void
OnAccept
(
AChannel
channel
)
{
Session
session
=
ComponentFactory
.
CreateWithParent
<
Session
,
NetworkComponent
,
AChannel
>(
this
,
this
,
channel
);
Session
session
=
ComponentFactory
.
CreateWithParent
<
Session
,
AChannel
>(
this
,
channel
);
this
.
sessions
.
Add
(
session
.
Id
,
session
);
}
...
...
@@ -100,7 +105,7 @@ namespace ETModel
public
Session
Create
(
IPEndPoint
ipEndPoint
)
{
AChannel
channel
=
this
.
Service
.
ConnectChannel
(
ipEndPoint
);
Session
session
=
ComponentFactory
.
CreateWithParent
<
Session
,
NetworkComponent
,
AChannel
>(
this
,
this
,
channel
);
Session
session
=
ComponentFactory
.
CreateWithParent
<
Session
,
AChannel
>(
this
,
channel
);
this
.
sessions
.
Add
(
session
.
Id
,
session
);
return
session
;
}
...
...
Unity/Assets/Scripts/Module/Message/Session.cs
浏览文件 @
266eda7c
...
...
@@ -9,20 +9,11 @@ using System.Threading.Tasks;
namespace
ETModel
{
[
ObjectSystem
]
public
class
SessionAwakeSystem
:
AwakeSystem
<
Session
,
NetworkComponent
,
AChannel
>
public
class
SessionAwakeSystem
:
AwakeSystem
<
Session
,
AChannel
>
{
public
override
void
Awake
(
Session
self
,
NetworkComponent
a
,
AChannel
b
)
public
override
void
Awake
(
Session
self
,
AChannel
b
)
{
self
.
Awake
(
a
,
b
);
}
}
[
ObjectSystem
]
public
class
SessionStartSystem
:
StartSystem
<
Session
>
{
public
override
void
Start
(
Session
self
)
{
self
.
Start
();
self
.
Awake
(
b
);
}
}
...
...
@@ -43,7 +34,7 @@ namespace ETModel
}
}
public
void
Awake
(
NetworkComponent
net
,
AChannel
aChannel
)
public
void
Awake
(
AChannel
aChannel
)
{
this
.
Error
=
0
;
this
.
channel
=
aChannel
;
...
...
@@ -55,13 +46,9 @@ namespace ETModel
this
.
Network
.
Remove
(
this
.
Id
);
};
channel
.
ReadCallback
+=
this
.
OnRead
;
this
.
channel
.
Start
();
}
public
void
Start
()
{
this
.
channel
?.
Start
();
}
public
override
void
Dispose
()
{
if
(
this
.
IsDisposed
)
...
...
@@ -77,7 +64,7 @@ namespace ETModel
{
action
.
Invoke
(
new
ResponseMessage
{
Error
=
ErrorCode
.
ERR_SessionDispose
});
}
this
.
Error
=
0
;
this
.
channel
.
Dispose
();
this
.
Network
.
Remove
(
id
);
...
...
@@ -143,7 +130,7 @@ namespace ETModel
catch
(
Exception
e
)
{
// 出现任何消息解析异常都要断开Session,防止客户端伪造消息
Log
.
Error
(
e
);
Log
.
Error
(
$"opcode:
{
opcode
}
{
this
.
Network
.
Count
}
{
e
}
"
);
this
.
Error
=
ErrorCode
.
ERR_PacketParserError
;
this
.
Network
.
Remove
(
this
.
Id
);
return
;
...
...
Unity/Hotfix/Base/Object/ComponentWithId.cs
浏览文件 @
266eda7c
...
...
@@ -14,7 +14,6 @@ namespace ETHotfix
protected
ComponentWithId
()
{
this
.
Id
=
this
.
InstanceId
;
}
protected
ComponentWithId
(
long
id
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录