Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
老鱼er
et
提交
7cb15395
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,发现更多精彩内容 >>
提交
7cb15395
编写于
1月 07, 2015
作者:
T
tanghai
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
去除TChannel的start函数,channel一创建就在构造函数中startrecv
上级
2a6edd13
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
37 addition
and
37 deletion
+37
-37
CSharp/Platform/TNet/TChannel.cs
CSharp/Platform/TNet/TChannel.cs
+37
-35
CSharp/Platform/TNet/TService.cs
CSharp/Platform/TNet/TService.cs
+0
-2
未找到文件。
CSharp/Platform/TNet/TChannel.cs
浏览文件 @
7cb15395
...
...
@@ -28,6 +28,8 @@ namespace TNet
this
.
service
=
service
;
this
.
parser
=
new
PacketParser
(
recvBuffer
);
this
.
remoteAddress
=
this
.
socket
.
RemoteAddress
;
StartRecv
();
}
protected
virtual
void
Dispose
(
bool
disposing
)
...
...
@@ -66,7 +68,7 @@ namespace TNet
this
.
sendBuffer
.
SendTo
(
buffer
);
if
(
this
.
sendTimer
==
ObjectId
.
Empty
)
{
this
.
sendTimer
=
this
.
service
.
Timer
.
Add
(
TimeHelper
.
Now
()
+
SendInterval
,
this
.
S
endTimerCallback
);
this
.
sendTimer
=
this
.
service
.
Timer
.
Add
(
TimeHelper
.
Now
()
+
SendInterval
,
this
.
S
tartSend
);
}
}
...
...
@@ -78,39 +80,6 @@ namespace TNet
}
}
private
async
void
SendTimerCallback
()
{
try
{
while
(
true
)
{
if
(
this
.
sendBuffer
.
Count
==
0
)
{
break
;
}
int
sendSize
=
TBuffer
.
ChunkSize
-
this
.
sendBuffer
.
FirstIndex
;
if
(
sendSize
>
this
.
sendBuffer
.
Count
)
{
sendSize
=
this
.
sendBuffer
.
Count
;
}
int
n
=
await
this
.
socket
.
SendAsync
(
this
.
sendBuffer
.
First
,
this
.
sendBuffer
.
FirstIndex
,
sendSize
);
this
.
sendBuffer
.
FirstIndex
+=
n
;
if
(
this
.
sendBuffer
.
FirstIndex
==
TBuffer
.
ChunkSize
)
{
this
.
sendBuffer
.
FirstIndex
=
0
;
this
.
sendBuffer
.
RemoveFirst
();
}
}
}
catch
(
Exception
e
)
{
Log
.
Trace
(
e
.
ToString
());
}
this
.
sendTimer
=
ObjectId
.
Empty
;
}
public
Task
<
byte
[
]>
RecvAsync
()
{
var
tcs
=
new
TaskCompletionSource
<
byte
[
]>
();
...
...
@@ -146,7 +115,40 @@ namespace TNet
tcs
.
SetResult
(
packet
);
}
public
async
void
Start
()
private
async
void
StartSend
()
{
try
{
while
(
true
)
{
if
(
this
.
sendBuffer
.
Count
==
0
)
{
break
;
}
int
sendSize
=
TBuffer
.
ChunkSize
-
this
.
sendBuffer
.
FirstIndex
;
if
(
sendSize
>
this
.
sendBuffer
.
Count
)
{
sendSize
=
this
.
sendBuffer
.
Count
;
}
int
n
=
await
this
.
socket
.
SendAsync
(
this
.
sendBuffer
.
First
,
this
.
sendBuffer
.
FirstIndex
,
sendSize
);
this
.
sendBuffer
.
FirstIndex
+=
n
;
if
(
this
.
sendBuffer
.
FirstIndex
==
TBuffer
.
ChunkSize
)
{
this
.
sendBuffer
.
FirstIndex
=
0
;
this
.
sendBuffer
.
RemoveFirst
();
}
}
}
catch
(
Exception
e
)
{
Log
.
Trace
(
e
.
ToString
());
}
this
.
sendTimer
=
ObjectId
.
Empty
;
}
private
async
void
StartRecv
()
{
try
{
...
...
CSharp/Platform/TNet/TService.cs
浏览文件 @
7cb15395
...
...
@@ -71,7 +71,6 @@ namespace TNet
await
newSocket
.
ConnectAsync
(
host
,
port
);
TChannel
channel
=
new
TChannel
(
newSocket
,
this
);
channels
[
newSocket
.
RemoteAddress
]
=
channel
;
channel
.
Start
();
return
channel
;
}
...
...
@@ -85,7 +84,6 @@ namespace TNet
await
acceptor
.
AcceptAsync
(
socket
);
TChannel
channel
=
new
TChannel
(
socket
,
this
);
channels
[
channel
.
RemoteAddress
]
=
channel
;
channel
.
Start
();
return
channel
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录