Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
老鱼er
et
提交
b4cdeac0
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,发现更多精彩内容 >>
提交
b4cdeac0
编写于
1月 28, 2013
作者:
T
tanghai
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
格式化一下代码
上级
539e9d42
变更
41
隐藏空白更改
内联
并排
Showing
41 changed file
with
223 addition
and
257 deletion
+223
-257
CSharp/App/Editor/Bootstrapper.cs
CSharp/App/Editor/Bootstrapper.cs
+3
-1
CSharp/App/Infrastructure/AutoPopulateExportedViewsBehavior.cs
...p/App/Infrastructure/AutoPopulateExportedViewsBehavior.cs
+1
-5
CSharp/App/Infrastructure/IViewRegionRegistration.cs
CSharp/App/Infrastructure/IViewRegionRegistration.cs
+1
-4
CSharp/App/Infrastructure/ViewExportAttribute.cs
CSharp/App/Infrastructure/ViewExportAttribute.cs
+1
-5
CSharp/App/Modules/BehaviorTree/BehaviorTreeLayout.cs
CSharp/App/Modules/BehaviorTree/BehaviorTreeLayout.cs
+8
-4
CSharp/App/Modules/BehaviorTree/BehaviorTreeViewModel.cs
CSharp/App/Modules/BehaviorTree/BehaviorTreeViewModel.cs
+4
-2
CSharp/App/Modules/BehaviorTree/TreeNode.cs
CSharp/App/Modules/BehaviorTree/TreeNode.cs
+3
-15
CSharp/App/Modules/BehaviorTree/TreeNodeViewModel.cs
CSharp/App/Modules/BehaviorTree/TreeNodeViewModel.cs
+3
-1
CSharp/App/Modules/Robot/Packages.config
CSharp/App/Modules/Robot/Packages.config
+0
-2
CSharp/App/Modules/Robot/Protos/Messages.cs
CSharp/App/Modules/Robot/Protos/Messages.cs
+54
-53
CSharp/App/Modules/Robot/RealmException.cs
CSharp/App/Modules/Robot/RealmException.cs
+1
-5
CSharp/App/Modules/Robot/RealmInfo.cs
CSharp/App/Modules/Robot/RealmInfo.cs
+3
-12
CSharp/App/Modules/Robot/RealmSession.cs
CSharp/App/Modules/Robot/RealmSession.cs
+30
-31
CSharp/App/Modules/Robot/Robot.csproj
CSharp/App/Modules/Robot/Robot.csproj
+0
-10
CSharp/App/Modules/Robot/RobotView.xaml.cs
CSharp/App/Modules/Robot/RobotView.xaml.cs
+0
-1
CSharp/App/Modules/Robot/RobotViewModel.cs
CSharp/App/Modules/Robot/RobotViewModel.cs
+3
-2
CSharp/App/Modules/WaiGua/WaiGuaViewModel.cs
CSharp/App/Modules/WaiGua/WaiGuaViewModel.cs
+2
-1
CSharp/CSharp.sln.DotSettings
CSharp/CSharp.sln.DotSettings
+2
-1
CSharp/Contract/RealmContract/ICalculator.cs
CSharp/Contract/RealmContract/ICalculator.cs
+2
-2
CSharp/Contract/RealmContract/Properties/AssemblyInfo.cs
CSharp/Contract/RealmContract/Properties/AssemblyInfo.cs
+5
-2
CSharp/Platform/ENet/ClientHost.cs
CSharp/Platform/ENet/ClientHost.cs
+14
-12
CSharp/Platform/ENet/ENetException.cs
CSharp/Platform/ENet/ENetException.cs
+1
-5
CSharp/Platform/ENet/Event.cs
CSharp/Platform/ENet/Event.cs
+3
-3
CSharp/Platform/ENet/Host.cs
CSharp/Platform/ENet/Host.cs
+2
-3
CSharp/Platform/ENet/NativeMethods.cs
CSharp/Platform/ENet/NativeMethods.cs
+14
-7
CSharp/Platform/ENet/NativeStructs.cs
CSharp/Platform/ENet/NativeStructs.cs
+7
-3
CSharp/Platform/ENet/Packet.cs
CSharp/Platform/ENet/Packet.cs
+0
-2
CSharp/Platform/ENet/Peer.cs
CSharp/Platform/ENet/Peer.cs
+0
-1
CSharp/Platform/ENet/ServerHost.cs
CSharp/Platform/ENet/ServerHost.cs
+12
-13
CSharp/Platform/ENetTest/ENetClientServerTest.cs
CSharp/Platform/ENetTest/ENetClientServerTest.cs
+2
-2
CSharp/Platform/ENetTest/Properties/AssemblyInfo.cs
CSharp/Platform/ENetTest/Properties/AssemblyInfo.cs
+5
-2
CSharp/Platform/Helper/ByteHelper.cs
CSharp/Platform/Helper/ByteHelper.cs
+5
-6
CSharp/Platform/Helper/JsonHelper.cs
CSharp/Platform/Helper/JsonHelper.cs
+6
-10
CSharp/Platform/Helper/LoaderHelper.cs
CSharp/Platform/Helper/LoaderHelper.cs
+2
-4
CSharp/Platform/Helper/Properties/AssemblyInfo.cs
CSharp/Platform/Helper/Properties/AssemblyInfo.cs
+5
-2
CSharp/Platform/Helper/ProtobufHelper.cs
CSharp/Platform/Helper/ProtobufHelper.cs
+1
-1
CSharp/Platform/Helper/StringHelper.cs
CSharp/Platform/Helper/StringHelper.cs
+1
-1
CSharp/Platform/Helper/XmlHelper.cs
CSharp/Platform/Helper/XmlHelper.cs
+7
-7
CSharp/Platform/Hooks/RecvHook.cs
CSharp/Platform/Hooks/RecvHook.cs
+4
-2
CSharp/Platform/Hooks/SendHook.cs
CSharp/Platform/Hooks/SendHook.cs
+4
-2
CSharp/Platform/Log/StackInfoDecorater.cs
CSharp/Platform/Log/StackInfoDecorater.cs
+2
-10
未找到文件。
CSharp/App/Editor/Bootstrapper.cs
浏览文件 @
b4cdeac0
...
@@ -30,7 +30,9 @@ namespace Editor
...
@@ -30,7 +30,9 @@ namespace Editor
protected
override
IRegionBehaviorFactory
ConfigureDefaultRegionBehaviors
()
protected
override
IRegionBehaviorFactory
ConfigureDefaultRegionBehaviors
()
{
{
IRegionBehaviorFactory
factory
=
base
.
ConfigureDefaultRegionBehaviors
();
IRegionBehaviorFactory
factory
=
base
.
ConfigureDefaultRegionBehaviors
();
factory
.
AddIfMissing
(
"AutoPopulateExportedViewsBehavior"
,
typeof
(
AutoPopulateExportedViewsBehavior
));
factory
.
AddIfMissing
(
"AutoPopulateExportedViewsBehavior"
,
typeof
(
AutoPopulateExportedViewsBehavior
));
return
factory
;
return
factory
;
}
}
...
...
CSharp/App/Infrastructure/AutoPopulateExportedViewsBehavior.cs
浏览文件 @
b4cdeac0
...
@@ -25,11 +25,7 @@ namespace Infrastructure
...
@@ -25,11 +25,7 @@ namespace Infrastructure
public
class
AutoPopulateExportedViewsBehavior
:
RegionBehavior
,
IPartImportsSatisfiedNotification
public
class
AutoPopulateExportedViewsBehavior
:
RegionBehavior
,
IPartImportsSatisfiedNotification
{
{
[
ImportMany
(
AllowRecomposition
=
true
)]
[
ImportMany
(
AllowRecomposition
=
true
)]
public
Lazy
<
object
,
IViewRegionRegistration
>[]
RegisteredViews
public
Lazy
<
object
,
IViewRegionRegistration
>[]
RegisteredViews
{
get
;
set
;
}
{
get
;
set
;
}
#
region
IPartImportsSatisfiedNotification
Members
#
region
IPartImportsSatisfiedNotification
Members
...
...
CSharp/App/Infrastructure/IViewRegionRegistration.cs
浏览文件 @
b4cdeac0
...
@@ -19,9 +19,6 @@ namespace Infrastructure
...
@@ -19,9 +19,6 @@ namespace Infrastructure
{
{
public
interface
IViewRegionRegistration
public
interface
IViewRegionRegistration
{
{
string
RegionName
string
RegionName
{
get
;
}
{
get
;
}
}
}
}
}
\ No newline at end of file
CSharp/App/Infrastructure/ViewExportAttribute.cs
浏览文件 @
b4cdeac0
...
@@ -33,11 +33,7 @@ namespace Infrastructure
...
@@ -33,11 +33,7 @@ namespace Infrastructure
#
region
IViewRegionRegistration
Members
#
region
IViewRegionRegistration
Members
public
string
RegionName
public
string
RegionName
{
get
;
set
;
}
{
get
;
set
;
}
#
endregion
#
endregion
}
}
...
...
CSharp/App/Modules/BehaviorTree/BehaviorTreeLayout.cs
浏览文件 @
b4cdeac0
...
@@ -11,7 +11,8 @@ namespace Modules.BehaviorTree
...
@@ -11,7 +11,8 @@ namespace Modules.BehaviorTree
private
static
double
rootOffsetX
;
private
static
double
rootOffsetX
;
private
static
double
rootOffsetY
;
private
static
double
rootOffsetY
;
private
static
TreeNodeViewModel
LeftMostOffspring
(
TreeNodeViewModel
treeNode
,
int
currentLevel
,
int
searchLevel
)
private
static
TreeNodeViewModel
LeftMostOffspring
(
TreeNodeViewModel
treeNode
,
int
currentLevel
,
int
searchLevel
)
{
{
if
(
currentLevel
==
searchLevel
)
if
(
currentLevel
==
searchLevel
)
{
{
...
@@ -31,7 +32,8 @@ namespace Modules.BehaviorTree
...
@@ -31,7 +32,8 @@ namespace Modules.BehaviorTree
return
null
;
return
null
;
}
}
private
static
TreeNodeViewModel
RightMostOffspring
(
TreeNodeViewModel
treeNode
,
int
currentLevel
,
int
searchLevel
)
private
static
TreeNodeViewModel
RightMostOffspring
(
TreeNodeViewModel
treeNode
,
int
currentLevel
,
int
searchLevel
)
{
{
if
(
currentLevel
==
searchLevel
)
if
(
currentLevel
==
searchLevel
)
{
{
...
@@ -126,10 +128,12 @@ namespace Modules.BehaviorTree
...
@@ -126,10 +128,12 @@ namespace Modules.BehaviorTree
treeNode
.
Prelim
=
prelim
;
treeNode
.
Prelim
=
prelim
;
treeNode
.
Modify
=
modify
;
treeNode
.
Modify
=
modify
;
Logger
.
Debug
(
"Num: "
+
treeNode
.
Num
+
" Prelim: "
+
treeNode
.
Prelim
+
" Modify: "
+
treeNode
.
Modify
);
Logger
.
Debug
(
"Num: "
+
treeNode
.
Num
+
" Prelim: "
+
treeNode
.
Prelim
+
" Modify: "
+
treeNode
.
Modify
);
}
}
private
static
void
CalculateRelativeXAndY
(
TreeNodeViewModel
treeNode
,
int
level
,
double
totalModify
)
private
static
void
CalculateRelativeXAndY
(
TreeNodeViewModel
treeNode
,
int
level
,
double
totalModify
)
{
{
foreach
(
TreeNodeViewModel
node
in
treeNode
.
Children
)
foreach
(
TreeNodeViewModel
node
in
treeNode
.
Children
)
{
{
...
...
CSharp/App/Modules/BehaviorTree/BehaviorTreeViewModel.cs
浏览文件 @
b4cdeac0
...
@@ -3,10 +3,12 @@ using System.ComponentModel.Composition;
...
@@ -3,10 +3,12 @@ using System.ComponentModel.Composition;
namespace
Modules.BehaviorTree
namespace
Modules.BehaviorTree
{
{
[
Export
(
contractType
:
typeof
(
BehaviorTreeViewModel
)),
PartCreationPolicy
(
creationPolicy
:
CreationPolicy
.
NonShared
)]
[
Export
(
contractType
:
typeof
(
BehaviorTreeViewModel
)),
PartCreationPolicy
(
creationPolicy
:
CreationPolicy
.
NonShared
)]
internal
class
BehaviorTreeViewModel
internal
class
BehaviorTreeViewModel
{
{
private
readonly
ObservableCollection
<
TreeNodeViewModel
>
treeNodes
=
new
ObservableCollection
<
TreeNodeViewModel
>();
private
readonly
ObservableCollection
<
TreeNodeViewModel
>
treeNodes
=
new
ObservableCollection
<
TreeNodeViewModel
>();
public
ObservableCollection
<
TreeNodeViewModel
>
TreeNodes
public
ObservableCollection
<
TreeNodeViewModel
>
TreeNodes
{
{
...
...
CSharp/App/Modules/BehaviorTree/TreeNode.cs
浏览文件 @
b4cdeac0
...
@@ -8,22 +8,10 @@
...
@@ -8,22 +8,10 @@
this
.
Y
=
y
;
this
.
Y
=
y
;
}
}
public
double
X
public
double
X
{
get
;
set
;
}
{
get
;
set
;
}
public
double
Y
public
double
Y
{
get
;
set
;
}
{
get
;
set
;
}
public
int
Type
public
int
Type
{
get
;
set
;
}
{
get
;
set
;
}
}
}
}
}
\ No newline at end of file
CSharp/App/Modules/BehaviorTree/TreeNodeViewModel.cs
浏览文件 @
b4cdeac0
...
@@ -16,7 +16,9 @@ namespace Modules.BehaviorTree
...
@@ -16,7 +16,9 @@ namespace Modules.BehaviorTree
private
double
modify
;
private
double
modify
;
private
double
ancestorModify
;
private
double
ancestorModify
;
private
TreeNodeViewModel
parent
;
private
TreeNodeViewModel
parent
;
private
ObservableCollection
<
TreeNodeViewModel
>
children
=
new
ObservableCollection
<
TreeNodeViewModel
>();
private
ObservableCollection
<
TreeNodeViewModel
>
children
=
new
ObservableCollection
<
TreeNodeViewModel
>();
public
TreeNodeViewModel
(
TreeNode
treeNode
,
TreeNodeViewModel
parent
)
public
TreeNodeViewModel
(
TreeNode
treeNode
,
TreeNodeViewModel
parent
)
{
{
...
...
CSharp/App/Modules/Robot/Packages.config
浏览文件 @
b4cdeac0
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
<
packages
>
<
packages
>
<
package
id
=
"BouncyCastle"
version
=
"1.7.0"
targetFramework
=
"net45"
/>
<
package
id
=
"BouncyCastle"
version
=
"1.7.0"
targetFramework
=
"net45"
/>
<
package
id
=
"CommonServiceLocator"
version
=
"1.0"
targetFramework
=
"net45"
/>
<
package
id
=
"CommonServiceLocator"
version
=
"1.0"
targetFramework
=
"net45"
/>
<
package
id
=
"Google.ProtocolBuffers"
version
=
"2.4.1.473"
targetFramework
=
"net45"
/>
<
package
id
=
"Prism"
version
=
"4.1.0.0"
targetFramework
=
"net45"
/>
<
package
id
=
"Prism"
version
=
"4.1.0.0"
targetFramework
=
"net45"
/>
<
package
id
=
"Prism.MEFExtensions"
version
=
"4.1.0.0"
targetFramework
=
"net45"
/>
<
package
id
=
"Prism.MEFExtensions"
version
=
"4.1.0.0"
targetFramework
=
"net45"
/>
<
package
id
=
"protobuf-net"
version
=
"2.0.0.621"
targetFramework
=
"net45"
/>
</
packages
>
</
packages
>
\ No newline at end of file
CSharp/App/Modules/Robot/Protos/Messages.cs
浏览文件 @
b4cdeac0
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
System.Runtime.Serialization
;
using
System.Runtime.Serialization
;
using
ProtoBuf
;
namespace
Robot.Protos
namespace
Robot.Protos
{
{
...
@@ -23,83 +22,85 @@ namespace Robot.Protos
...
@@ -23,83 +22,85 @@ namespace Robot.Protos
public
class
CMSG_AuthLogonPermit
public
class
CMSG_AuthLogonPermit
{
{
[
DataMember
(
Order
=
1
,
IsRequired
=
true
)]
[
DataMember
(
Order
=
1
,
IsRequired
=
true
)]
public
string
Account
public
string
Account
{
get
;
set
;
}
{
get
;
set
;
}
[
DataMember
(
Order
=
2
,
IsRequired
=
true
)]
[
DataMember
(
Order
=
2
,
IsRequired
=
true
)]
public
string
PasswordMd5
public
string
PasswordMd5
{
get
;
set
;
}
{
get
;
set
;
}
}
}
[
DataContract
]
[
DataContract
]
public
class
SMSG_Lock_For_Safe_Time
public
class
SMSG_Lock_For_Safe_Time
{
{
[
DataMember
(
Order
=
1
,
IsRequired
=
true
)]
[
DataMember
(
Order
=
1
,
IsRequired
=
true
)]
public
uint
Time
public
uint
Time
{
get
;
set
;
}
{
get
;
set
;
}
}
}
[
DataContract
]
[
DataContract
]
public
class
SMSG_Password_Protect_Type
public
class
SMSG_Password_Protect_Type
{
{
[
DataMember
(
Order
=
1
,
IsRequired
=
true
)]
[
DataMember
(
Order
=
1
,
IsRequired
=
true
)]
public
uint
Code
public
uint
Code
{
get
;
set
;
}
{
get
;
set
;
}
[
DataMember
(
Order
=
2
,
IsRequired
=
true
)]
[
DataMember
(
Order
=
2
,
IsRequired
=
true
)]
public
uint
SubCode
public
uint
SubCode
{
get
;
set
;
}
{
get
;
set
;
}
[
DataMember
(
Order
=
3
,
IsRequired
=
true
)]
[
DataMember
(
Order
=
3
,
IsRequired
=
true
)]
public
uint
PasswordProtectType
public
uint
PasswordProtectType
{
get
;
set
;
}
{
get
;
set
;
}
[
DataMember
(
Order
=
4
,
IsRequired
=
false
)]
[
DataMember
(
Order
=
4
,
IsRequired
=
false
)]
public
byte
[]
PpcCoordinate
public
byte
[]
PpcCoordinate
{
get
;
set
;
}
{
get
;
set
;
}
}
}
[
DataContract
]
[
DataContract
]
public
class
SMSG_Auth_Challenge
public
class
SMSG_Auth_Challenge
{
{
[
DataMember
(
Order
=
1
,
IsRequired
=
true
)]
[
DataMember
(
Order
=
1
,
IsRequired
=
true
)]
public
uint
Num
public
uint
Num
{
get
;
set
;
}
{
get
;
set
;
}
[
DataMember
(
Order
=
2
,
IsRequired
=
true
)]
[
DataMember
(
Order
=
2
,
IsRequired
=
true
)]
public
uint
Seed
public
uint
Seed
{
get
;
set
;
}
{
get
;
set
;
}
[
DataMember
(
Order
=
3
)]
[
DataMember
(
Order
=
3
)]
public
List
<
uint
>
Random
public
List
<
uint
>
Random
{
get
;
set
;
}
{
}
get
;
set
;
[
DataContract
]
}
public
class
CMSG_AuthLogonChallenge
{
[
DataMember
(
Order
=
1
,
IsRequired
=
true
)]
public
string
GameName
{
get
;
set
;
}
[
DataMember
(
Order
=
2
,
IsRequired
=
true
)]
public
uint
Version1
{
get
;
set
;
}
[
DataMember
(
Order
=
3
,
IsRequired
=
true
)]
public
uint
Version2
{
get
;
set
;
}
[
DataMember
(
Order
=
4
,
IsRequired
=
true
)]
public
uint
Version3
{
get
;
set
;
}
[
DataMember
(
Order
=
5
,
IsRequired
=
true
)]
public
uint
Build
{
get
;
set
;
}
[
DataMember
(
Order
=
6
,
IsRequired
=
true
)]
public
uint
Platform
{
get
;
set
;
}
[
DataMember
(
Order
=
7
,
IsRequired
=
true
)]
public
uint
OS
{
get
;
set
;
}
[
DataMember
(
Order
=
8
,
IsRequired
=
true
)]
public
uint
Country
{
get
;
set
;
}
[
DataMember
(
Order
=
9
,
IsRequired
=
true
)]
public
uint
TimeMapBias
{
get
;
set
;
}
[
DataMember
(
Order
=
10
,
IsRequired
=
true
)]
public
uint
IP
{
get
;
set
;
}
[
DataMember
(
Order
=
11
,
IsRequired
=
true
)]
public
byte
[]
Password
{
get
;
set
;
}
[
DataMember
(
Order
=
12
,
IsRequired
=
true
)]
public
byte
[]
I
{
get
;
set
;
}
}
}
}
}
\ No newline at end of file
CSharp/App/Modules/Robot/RealmException.cs
浏览文件 @
b4cdeac0
using
System
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
namespace
Robot
namespace
Robot
{
{
...
@@ -12,4 +8,4 @@ namespace Robot
...
@@ -12,4 +8,4 @@ namespace Robot
{
{
}
}
}
}
}
}
\ No newline at end of file
CSharp/App/Modules/Robot/RealmInfo.cs
浏览文件 @
b4cdeac0
using
System
;
using
Robot.Protos
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
using
Robot.Protos
;
namespace
Robot
namespace
Robot
{
{
public
class
RealmInfo
public
class
RealmInfo
{
{
public
SMSG_Password_Protect_Type
SmsgPasswordProtectType
public
SMSG_Password_Protect_Type
SmsgPasswordProtectType
{
get
;
set
;
}
{
get
;
set
;
}
}
}
}
}
\ No newline at end of file
CSharp/App/Modules/Robot/RealmSession.cs
浏览文件 @
b4cdeac0
using
System
;
using
System
;
using
System.IO
;
using
System.Net
;
using
System.Net
;
using
System.Net.Sockets
;
using
System.Net.Sockets
;
using
System.Threading.Tasks
;
using
System.Threading.Tasks
;
using
Helper
;
using
Helper
;
using
Log
;
using
Log
;
using
Org.BouncyCastle.Crypto.Digests
;
using
Org.BouncyCastle.Utilities.Encoders
;
using
Org.BouncyCastle.Utilities.Encoders
;
using
ProtoBuf
;
using
Robot.Protos
;
using
Robot.Protos
;
using
Helper
;
using
Org.BouncyCastle.Crypto.Digests
;
namespace
Robot
namespace
Robot
{
{
public
class
RealmSession
:
IDisposable
public
class
RealmSession
:
IDisposable
{
{
private
readonly
NetworkStream
networkStream
;
private
readonly
NetworkStream
networkStream
;
private
RealmInfo
realmInfo
=
new
RealmInfo
();
private
readonly
RealmInfo
realmInfo
=
new
RealmInfo
();
public
RealmSession
(
string
host
,
ushort
port
)
public
RealmSession
(
string
host
,
ushort
port
)
{
{
Socket
socket
=
ConnectSocket
(
host
,
port
);
Socket
socket
=
ConnectSocket
(
host
,
port
);
networkStream
=
new
NetworkStream
(
socket
);
this
.
networkStream
=
new
NetworkStream
(
socket
);
}
}
public
void
Dispose
()
public
void
Dispose
()
{
{
networkStream
.
Dispose
();
this
.
networkStream
.
Dispose
();
}
}
public
static
Socket
ConnectSocket
(
string
host
,
ushort
port
)
public
static
Socket
ConnectSocket
(
string
host
,
ushort
port
)
...
@@ -54,27 +51,27 @@ namespace Robot
...
@@ -54,27 +51,27 @@ namespace Robot
public
async
void
SendMessage
<
T
>(
ushort
opcode
,
T
message
)
public
async
void
SendMessage
<
T
>(
ushort
opcode
,
T
message
)
{
{
byte
[]
protoBytes
=
ProtobufHelper
.
ToBytes
(
message
);
byte
[]
protoBytes
=
ProtobufHelper
.
ToBytes
(
message
);
var
neworkBytes
=
new
byte
[
sizeof
(
int
)
+
sizeof
(
ushort
)
+
protoBytes
.
Length
];
var
neworkBytes
=
new
byte
[
sizeof
(
int
)
+
sizeof
(
ushort
)
+
protoBytes
.
Length
];
int
totalSize
=
sizeof
(
ushort
)
+
protoBytes
.
Length
;
int
totalSize
=
sizeof
(
ushort
)
+
protoBytes
.
Length
;
var
totalSizeBytes
=
BitConverter
.
GetBytes
(
totalSize
);
var
totalSizeBytes
=
BitConverter
.
GetBytes
(
totalSize
);
totalSizeBytes
.
CopyTo
(
neworkBytes
,
0
);
totalSizeBytes
.
CopyTo
(
neworkBytes
,
0
);
var
opcodeBytes
=
BitConverter
.
GetBytes
(
opcode
);
var
opcodeBytes
=
BitConverter
.
GetBytes
(
opcode
);
opcodeBytes
.
CopyTo
(
neworkBytes
,
sizeof
(
int
));
opcodeBytes
.
CopyTo
(
neworkBytes
,
sizeof
(
int
));
protoBytes
.
CopyTo
(
neworkBytes
,
sizeof
(
int
)
+
sizeof
(
ushort
));
protoBytes
.
CopyTo
(
neworkBytes
,
sizeof
(
int
)
+
sizeof
(
ushort
));
await
networkStream
.
WriteAsync
(
neworkBytes
,
0
,
neworkBytes
.
Length
);
await
this
.
networkStream
.
WriteAsync
(
neworkBytes
,
0
,
neworkBytes
.
Length
);
}
}
public
async
Task
<
bool
>
Handle_CMSG_AuthLogonPermit_Response
()
public
async
Task
<
bool
>
Handle_CMSG_AuthLogonPermit_Response
()
{
{
var
result
=
await
RecvMessage
();
var
result
=
await
this
.
RecvMessage
();
ushort
opcode
=
result
.
Item1
;
ushort
opcode
=
result
.
Item1
;
byte
[]
message
=
result
.
Item2
;
byte
[]
message
=
result
.
Item2
;
if
(
opcode
==
0
)
if
(
opcode
==
0
)
{
{
Logger
.
Trace
(
"opcode == 0"
);
Logger
.
Trace
(
"opcode == 0"
);
...
@@ -83,8 +80,7 @@ namespace Robot
...
@@ -83,8 +80,7 @@ namespace Robot
if
(
opcode
==
MessageOpcode
.
SMSG_LOCK_FOR_SAFE_TIME
)
if
(
opcode
==
MessageOpcode
.
SMSG_LOCK_FOR_SAFE_TIME
)
{
{
var
smsgLockForSafeTime
=
var
smsgLockForSafeTime
=
ProtobufHelper
.
FromBytes
<
SMSG_Lock_For_Safe_Time
>(
message
);
ProtobufHelper
.
FromBytes
<
SMSG_Lock_For_Safe_Time
>(
message
);
Logger
.
Trace
(
"account lock time: {0}"
,
smsgLockForSafeTime
.
Time
);
Logger
.
Trace
(
"account lock time: {0}"
,
smsgLockForSafeTime
.
Time
);
return
false
;
return
false
;
}
}
...
@@ -94,8 +90,7 @@ namespace Robot
...
@@ -94,8 +90,7 @@ namespace Robot
throw
new
RealmException
(
string
.
Format
(
"error opcode: {0}"
,
opcode
));
throw
new
RealmException
(
string
.
Format
(
"error opcode: {0}"
,
opcode
));
}
}
var
smsgPasswordProtectType
=
var
smsgPasswordProtectType
=
ProtobufHelper
.
FromBytes
<
SMSG_Password_Protect_Type
>(
message
);
ProtobufHelper
.
FromBytes
<
SMSG_Password_Protect_Type
>(
message
);
this
.
realmInfo
.
SmsgPasswordProtectType
=
smsgPasswordProtectType
;
this
.
realmInfo
.
SmsgPasswordProtectType
=
smsgPasswordProtectType
;
Logger
.
Trace
(
"message: {0}"
,
JsonHelper
.
ToString
(
smsgPasswordProtectType
));
Logger
.
Trace
(
"message: {0}"
,
JsonHelper
.
ToString
(
smsgPasswordProtectType
));
...
@@ -115,10 +110,11 @@ namespace Robot
...
@@ -115,10 +110,11 @@ namespace Robot
var
packetBytes
=
new
byte
[
needReadSize
];
var
packetBytes
=
new
byte
[
needReadSize
];
while
(
totalReadSize
!=
needReadSize
)
while
(
totalReadSize
!=
needReadSize
)
{
{
int
readSize
=
await
networkStream
.
ReadAsync
(
packetBytes
,
totalReadSize
,
packetBytes
.
Length
);
int
readSize
=
await
this
.
networkStream
.
ReadAsync
(
packetBytes
,
totalReadSize
,
packetBytes
.
Length
);
if
(
readSize
==
0
)
if
(
readSize
==
0
)
{
{
return
new
Tuple
<
ushort
,
byte
[
]>
(
0
,
new
byte
[]
{});
return
new
Tuple
<
ushort
,
byte
[
]>
(
0
,
new
byte
[]
{
});
}
}
totalReadSize
+=
readSize
;
totalReadSize
+=
readSize
;
}
}
...
@@ -131,15 +127,16 @@ namespace Robot
...
@@ -131,15 +127,16 @@ namespace Robot
var
contentBytes
=
new
byte
[
needReadSize
];
var
contentBytes
=
new
byte
[
needReadSize
];
while
(
totalReadSize
!=
needReadSize
)
while
(
totalReadSize
!=
needReadSize
)
{
{
int
readSize
=
await
networkStream
.
ReadAsync
(
contentBytes
,
totalReadSize
,
contentBytes
.
Length
);
int
readSize
=
await
this
.
networkStream
.
ReadAsync
(
contentBytes
,
totalReadSize
,
contentBytes
.
Length
);
if
(
readSize
==
0
)
if
(
readSize
==
0
)
{
{
return
new
Tuple
<
ushort
,
byte
[
]>
(
0
,
new
byte
[]
{});
return
new
Tuple
<
ushort
,
byte
[
]>
(
0
,
new
byte
[]
{
});
}
}
totalReadSize
+=
readSize
;
totalReadSize
+=
readSize
;
}
}
ushort
opcode
=
BitConverter
.
ToUInt16
(
contentBytes
,
0
);
ushort
opcode
=
BitConverter
.
ToUInt16
(
contentBytes
,
0
);
var
messageBytes
=
new
byte
[
needReadSize
-
sizeof
(
ushort
)];
var
messageBytes
=
new
byte
[
needReadSize
-
sizeof
(
ushort
)];
Array
.
Copy
(
contentBytes
,
sizeof
(
ushort
),
messageBytes
,
0
,
messageBytes
.
Length
);
Array
.
Copy
(
contentBytes
,
sizeof
(
ushort
),
messageBytes
,
0
,
messageBytes
.
Length
);
return
new
Tuple
<
ushort
,
byte
[
]>
(
opcode
,
messageBytes
);
return
new
Tuple
<
ushort
,
byte
[
]>
(
opcode
,
messageBytes
);
...
@@ -155,21 +152,23 @@ namespace Robot
...
@@ -155,21 +152,23 @@ namespace Robot
digest
.
DoFinal
(
passwordMd5
,
0
);
digest
.
DoFinal
(
passwordMd5
,
0
);
var
cmsgAuthLogonPermit
=
new
CMSG_AuthLogonPermit
var
cmsgAuthLogonPermit
=
new
CMSG_AuthLogonPermit
{
{
Account
=
account
,
Account
=
account
,
PasswordMd5
=
Hex
.
ToHexString
(
passwordMd5
)
PasswordMd5
=
Hex
.
ToHexString
(
passwordMd5
)
};
};
this
.
SendMessage
(
MessageOpcode
.
CMSG_AUTHLOGONPERMIT
,
cmsgAuthLogonPermit
);
this
.
SendMessage
(
MessageOpcode
.
CMSG_AUTHLOGONPERMIT
,
cmsgAuthLogonPermit
);
bool
result
=
await
Handle_CMSG_AuthLogonPermit_Response
();
bool
result
=
await
this
.
Handle_CMSG_AuthLogonPermit_Response
();
if
(
result
==
false
)
if
(
result
==
false
)
{
{
return
false
;
return
false
;
}
}
var
cmsgAuthLogonChallenge
=
new
CMSG_AuthLogonChallenge
{
};
return
true
;
return
true
;
}
}
}
}
}
}
\ No newline at end of file
CSharp/App/Modules/Robot/Robot.csproj
浏览文件 @
b4cdeac0
...
@@ -35,12 +35,6 @@
...
@@ -35,12 +35,6 @@
<Reference
Include=
"BouncyCastle.Crypto"
>
<Reference
Include=
"BouncyCastle.Crypto"
>
<HintPath>
..\..\..\packages\BouncyCastle.1.7.0\lib\Net20\BouncyCastle.Crypto.dll
</HintPath>
<HintPath>
..\..\..\packages\BouncyCastle.1.7.0\lib\Net20\BouncyCastle.Crypto.dll
</HintPath>
</Reference>
</Reference>
<Reference
Include=
"Google.ProtocolBuffers"
>
<HintPath>
..\..\..\packages\Google.ProtocolBuffers.2.4.1.473\lib\net40\Google.ProtocolBuffers.dll
</HintPath>
</Reference>
<Reference
Include=
"Google.ProtocolBuffers.Serialization"
>
<HintPath>
..\..\..\packages\Google.ProtocolBuffers.2.4.1.473\lib\net40\Google.ProtocolBuffers.Serialization.dll
</HintPath>
</Reference>
<Reference
Include=
"Microsoft.Practices.Prism"
>
<Reference
Include=
"Microsoft.Practices.Prism"
>
<HintPath>
..\..\..\packages\Prism.4.1.0.0\lib\NET40\Microsoft.Practices.Prism.dll
</HintPath>
<HintPath>
..\..\..\packages\Prism.4.1.0.0\lib\NET40\Microsoft.Practices.Prism.dll
</HintPath>
</Reference>
</Reference>
...
@@ -49,10 +43,6 @@
...
@@ -49,10 +43,6 @@
</Reference>
</Reference>
<Reference
Include=
"PresentationCore"
/>
<Reference
Include=
"PresentationCore"
/>
<Reference
Include=
"PresentationFramework"
/>
<Reference
Include=
"PresentationFramework"
/>
<Reference
Include=
"protobuf-net, Version=2.0.0.621, Culture=neutral, PublicKeyToken=257b51d87d2e4d67, processorArchitecture=MSIL"
>
<SpecificVersion>
False
</SpecificVersion>
<HintPath>
..\..\..\packages\protobuf-net.2.0.0.621\lib\net40\protobuf-net.dll
</HintPath>
</Reference>
<Reference
Include=
"System"
/>
<Reference
Include=
"System"
/>
<Reference
Include=
"System.ComponentModel.Composition"
/>
<Reference
Include=
"System.ComponentModel.Composition"
/>
<Reference
Include=
"System.Core"
/>
<Reference
Include=
"System.Core"
/>
...
...
CSharp/App/Modules/Robot/RobotView.xaml.cs
浏览文件 @
b4cdeac0
using
System.ComponentModel.Composition
;
using
System.ComponentModel.Composition
;
using
System.Windows
;
using
System.Windows
;
using
System.Windows.Controls
;
using
Infrastructure
;
using
Infrastructure
;
namespace
Modules.Robot
namespace
Modules.Robot
...
...
CSharp/App/Modules/Robot/RobotViewModel.cs
浏览文件 @
b4cdeac0
...
@@ -8,7 +8,8 @@ using Robot;
...
@@ -8,7 +8,8 @@ using Robot;
namespace
Modules.Robot
namespace
Modules.Robot
{
{
[
Export
(
contractType
:
typeof
(
RobotViewModel
)),
PartCreationPolicy
(
creationPolicy
:
CreationPolicy
.
NonShared
)]
[
Export
(
contractType
:
typeof
(
RobotViewModel
)),
PartCreationPolicy
(
creationPolicy
:
CreationPolicy
.
NonShared
)]
internal
sealed
class
RobotViewModel
:
NotificationObject
,
IDisposable
internal
sealed
class
RobotViewModel
:
NotificationObject
,
IDisposable
{
{
private
readonly
ClientHost
clientHost
;
private
readonly
ClientHost
clientHost
;
...
@@ -72,7 +73,7 @@ namespace Modules.Robot
...
@@ -72,7 +73,7 @@ namespace Modules.Robot
}
}
private
void
Disposing
(
bool
disposing
)
private
void
Disposing
(
bool
disposing
)
{
{
this
.
clientHost
.
Dispose
();
this
.
clientHost
.
Dispose
();
}
}
...
...
CSharp/App/Modules/WaiGua/WaiGuaViewModel.cs
浏览文件 @
b4cdeac0
...
@@ -4,7 +4,8 @@ using Microsoft.Practices.Prism.ViewModel;
...
@@ -4,7 +4,8 @@ using Microsoft.Practices.Prism.ViewModel;
namespace
Modules.WaiGua
namespace
Modules.WaiGua
{
{
[
Export
(
contractType
:
typeof
(
WaiGuaViewModel
)),
PartCreationPolicy
(
creationPolicy
:
CreationPolicy
.
NonShared
)]
[
Export
(
contractType
:
typeof
(
WaiGuaViewModel
)),
PartCreationPolicy
(
creationPolicy
:
CreationPolicy
.
NonShared
)]
internal
class
WaiGuaViewModel
:
NotificationObject
internal
class
WaiGuaViewModel
:
NotificationObject
{
{
private
string
logText
=
""
;
private
string
logText
=
""
;
...
...
CSharp/CSharp.sln.DotSettings
浏览文件 @
b4cdeac0
...
@@ -35,7 +35,7 @@
...
@@ -35,7 +35,7 @@
<s:Int64 x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/KEEP_BLANK_LINES_IN_DECLARATIONS/@EntryValue">1</s:Int64>
<s:Int64 x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/KEEP_BLANK_LINES_IN_DECLARATIONS/@EntryValue">1</s:Int64>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/KEEP_USER_LINEBREAKS/@EntryValue">False</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/KEEP_USER_LINEBREAKS/@EntryValue">False</s:Boolean>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/MODIFIERS_ORDER/@EntryValue">private public protected internal new abstract virtual override sealed static readonly extern unsafe volatile async</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/MODIFIERS_ORDER/@EntryValue">private public protected internal new abstract virtual override sealed static readonly extern unsafe volatile async</s:String>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/PLACE_ABSTRACT_ACCESSORHOLDER_ON_SINGLE_LINE/@EntryValue">False</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/PLACE_FIELD_ATTRIBUTE_ON_SAME_LINE/@EntryValue">False</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/PLACE_FIELD_ATTRIBUTE_ON_SAME_LINE/@EntryValue">False</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/PLACE_SIMPLE_ACCESSOR_ON_SINGLE_LINE/@EntryValue">False</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/PLACE_SIMPLE_ACCESSOR_ON_SINGLE_LINE/@EntryValue">False</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/PLACE_WHILE_ON_NEW_LINE/@EntryValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/PLACE_WHILE_ON_NEW_LINE/@EntryValue">True</s:Boolean>
...
@@ -50,6 +50,7 @@
...
@@ -50,6 +50,7 @@
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/WRAP_AFTER_INVOCATION_LPAR/@EntryValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/WRAP_AFTER_INVOCATION_LPAR/@EntryValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/WRAP_BEFORE_FIRST_TYPE_PARAMETER_CONSTRAINT/@EntryValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/WRAP_BEFORE_FIRST_TYPE_PARAMETER_CONSTRAINT/@EntryValue">True</s:Boolean>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/WRAP_FOR_STMT_HEADER_STYLE/@EntryValue">WRAP_IF_LONG</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/WRAP_FOR_STMT_HEADER_STYLE/@EntryValue">WRAP_IF_LONG</s:String>
<s:Int64 x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/WRAP_LIMIT/@EntryValue">100</s:Int64>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/WRAP_MULTIPLE_DECLARATION_STYLE/@EntryValue">WRAP_IF_LONG</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/WRAP_MULTIPLE_DECLARATION_STYLE/@EntryValue">WRAP_IF_LONG</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/WRAP_TERNARY_EXPR_STYLE/@EntryValue">WRAP_IF_LONG</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/WRAP_TERNARY_EXPR_STYLE/@EntryValue">WRAP_IF_LONG</s:String>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/JavaScriptCodeFormatting/JavaScriptFormatOther/ALIGN_MULTIPLE_DECLARATION/@EntryValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/JavaScriptCodeFormatting/JavaScriptFormatOther/ALIGN_MULTIPLE_DECLARATION/@EntryValue">True</s:Boolean>
...
...
CSharp/Contract/RealmContract/ICalculator.cs
浏览文件 @
b4cdeac0
...
@@ -3,8 +3,8 @@
...
@@ -3,8 +3,8 @@
namespace
RealmContract
namespace
RealmContract
{
{
[
ServiceContract
(
Name
=
"Calculator"
,
Namespace
=
"http://www.egametang.com/"
)]
[
ServiceContract
(
Name
=
"Calculator"
,
Namespace
=
"http://www.egametang.com/"
)]
public
interface
ICalculator
public
interface
ICalculator
{
{
double
Add
(
double
x
,
double
y
);
double
Add
(
double
x
,
double
y
);
}
}
}
}
\ No newline at end of file
CSharp/Contract/RealmContract/Properties/AssemblyInfo.cs
浏览文件 @
b4cdeac0
using
System.Reflection
;
using
System.Reflection
;
using
System.Runtime.CompilerServices
;
using
System.Runtime.InteropServices
;
using
System.Runtime.InteropServices
;
// 有关程序集的常规信息通过以下
// 有关程序集的常规信息通过以下
// 特性集控制。更改这些特性值可修改
// 特性集控制。更改这些特性值可修改
// 与程序集关联的信息。
// 与程序集关联的信息。
[
assembly
:
AssemblyTitle
(
"RealmContract"
)]
[
assembly
:
AssemblyTitle
(
"RealmContract"
)]
[
assembly
:
AssemblyDescription
(
""
)]
[
assembly
:
AssemblyDescription
(
""
)]
[
assembly
:
AssemblyConfiguration
(
""
)]
[
assembly
:
AssemblyConfiguration
(
""
)]
...
@@ -17,9 +17,11 @@ using System.Runtime.InteropServices;
...
@@ -17,9 +17,11 @@ using System.Runtime.InteropServices;
// 将 ComVisible 设置为 false 使此程序集中的类型
// 将 ComVisible 设置为 false 使此程序集中的类型
// 对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型,
// 对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型,
// 则将该类型上的 ComVisible 特性设置为 true。
// 则将该类型上的 ComVisible 特性设置为 true。
[
assembly
:
ComVisible
(
false
)]
[
assembly
:
ComVisible
(
false
)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[
assembly
:
Guid
(
"6c384393-17fe-4ebb-9b3e-5e913544999c"
)]
[
assembly
:
Guid
(
"6c384393-17fe-4ebb-9b3e-5e913544999c"
)]
// 程序集的版本信息由下面四个值组成:
// 程序集的版本信息由下面四个值组成:
...
@@ -32,5 +34,6 @@ using System.Runtime.InteropServices;
...
@@ -32,5 +34,6 @@ using System.Runtime.InteropServices;
// 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
// 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
// 方法是按如下所示使用“*”:
// 方法是按如下所示使用“*”:
// [assembly: AssemblyVersion("1.0.*")]
// [assembly: AssemblyVersion("1.0.*")]
[
assembly
:
AssemblyVersion
(
"1.0.0.0"
)]
[
assembly
:
AssemblyVersion
(
"1.0.0.0"
)]
[
assembly
:
AssemblyFileVersion
(
"1.0.0.0"
)]
[
assembly
:
AssemblyFileVersion
(
"1.0.0.0"
)]
\ No newline at end of file
CSharp/Platform/ENet/ClientHost.cs
浏览文件 @
b4cdeac0
using
System
;
using
System
;
using
System.Threading.Tasks
;
using
System.Threading.Tasks
;
using
Log
;
namespace
ENet
namespace
ENet
{
{
public
sealed
class
ClientHost
:
Host
public
sealed
class
ClientHost
:
Host
{
{
public
ClientHost
(
uint
peerLimit
=
NativeMethods
.
ENET_PROTOCOL_MAXIMUM_PEER_ID
,
public
ClientHost
(
uint
channelLimit
=
0
,
uint
incomingBandwidth
=
0
,
uint
peerLimit
=
NativeMethods
.
ENET_PROTOCOL_MAXIMUM_PEER_ID
,
uint
channelLimit
=
0
,
uint
outgoingBandwidth
=
0
,
bool
enableCrc
=
true
)
uint
incomingBandwidth
=
0
,
uint
outgoingBandwidth
=
0
,
bool
enableCrc
=
true
)
{
{
if
(
peerLimit
>
NativeMethods
.
ENET_PROTOCOL_MAXIMUM_PEER_ID
)
if
(
peerLimit
>
NativeMethods
.
ENET_PROTOCOL_MAXIMUM_PEER_ID
)
{
{
...
@@ -16,7 +15,8 @@ namespace ENet
...
@@ -16,7 +15,8 @@ namespace ENet
}
}
CheckChannelLimit
(
channelLimit
);
CheckChannelLimit
(
channelLimit
);
this
.
host
=
NativeMethods
.
enet_host_create
(
IntPtr
.
Zero
,
peerLimit
,
channelLimit
,
incomingBandwidth
,
outgoingBandwidth
);
this
.
host
=
NativeMethods
.
enet_host_create
(
IntPtr
.
Zero
,
peerLimit
,
channelLimit
,
incomingBandwidth
,
outgoingBandwidth
);
if
(
this
.
host
==
IntPtr
.
Zero
)
if
(
this
.
host
==
IntPtr
.
Zero
)
{
{
...
@@ -29,14 +29,16 @@ namespace ENet
...
@@ -29,14 +29,16 @@ namespace ENet
}
}
}
}
public
Task
<
Peer
>
ConnectAsync
(
public
Task
<
Peer
>
ConnectAsync
(
Address
address
,
Address
address
,
uint
channelLimit
=
NativeMethods
.
ENET_PROTOCOL_MAXIMUM_CHANNEL_COUNT
,
uint
data
=
0
)
uint
channelLimit
=
NativeMethods
.
ENET_PROTOCOL_MAXIMUM_CHANNEL_COUNT
,
uint
data
=
0
)
{
{
CheckChannelLimit
(
channelLimit
);
CheckChannelLimit
(
channelLimit
);
var
tcs
=
new
TaskCompletionSource
<
Peer
>();
var
tcs
=
new
TaskCompletionSource
<
Peer
>();
ENetAddress
nativeAddress
=
address
.
Struct
;
ENetAddress
nativeAddress
=
address
.
Struct
;
IntPtr
peerPtr
=
NativeMethods
.
enet_host_connect
(
this
.
host
,
ref
nativeAddress
,
channelLimit
,
data
);
IntPtr
peerPtr
=
NativeMethods
.
enet_host_connect
(
this
.
host
,
ref
nativeAddress
,
channelLimit
,
data
);
if
(
peerPtr
==
IntPtr
.
Zero
)
if
(
peerPtr
==
IntPtr
.
Zero
)
{
{
throw
new
ENetException
(
0
,
"Host connect call failed."
);
throw
new
ENetException
(
0
,
"Host connect call failed."
);
...
@@ -99,12 +101,12 @@ namespace ENet
...
@@ -99,12 +101,12 @@ namespace ENet
}
}
}
}
}
}
public
void
Start
(
int
timeout
=
0
)
public
void
Start
(
int
timeout
=
0
)
{
{
while
(
isRunning
)
while
(
this
.
isRunning
)
{
{
RunOnce
(
timeout
);
this
.
RunOnce
(
timeout
);
}
}
}
}
}
}
...
...
CSharp/Platform/ENet/ENetException.cs
浏览文件 @
b4cdeac0
...
@@ -9,10 +9,6 @@ namespace ENet
...
@@ -9,10 +9,6 @@ namespace ENet
this
.
Code
=
code
;
this
.
Code
=
code
;
}
}
public
int
Code
public
int
Code
{
get
;
private
set
;
}
{
get
;
private
set
;
}
}
}
}
}
\ No newline at end of file
CSharp/Platform/ENet/Event.cs
浏览文件 @
b4cdeac0
...
@@ -22,11 +22,11 @@ namespace ENet
...
@@ -22,11 +22,11 @@ namespace ENet
{
{
get
get
{
{
return
peerState
;
return
this
.
peerState
;
}
}
set
set
{
{
peerState
=
value
;
this
.
peerState
=
value
;
}
}
}
}
...
@@ -42,7 +42,7 @@ namespace ENet
...
@@ -42,7 +42,7 @@ namespace ENet
{
{
get
get
{
{
return
Ev
.
packet
;
return
this
.
Ev
.
packet
;
}
}
}
}
...
...
CSharp/Platform/ENet/Host.cs
浏览文件 @
b4cdeac0
using
System
;
using
System
;
using
System.Threading.Tasks
;
namespace
ENet
namespace
ENet
{
{
...
@@ -24,7 +23,7 @@ namespace ENet
...
@@ -24,7 +23,7 @@ namespace ENet
protected
bool
isRunning
=
true
;
protected
bool
isRunning
=
true
;
private
readonly
object
eventsLock
=
new
object
();
private
readonly
object
eventsLock
=
new
object
();
private
Action
events
;
private
Action
events
;
~
Host
()
~
Host
()
{
{
this
.
Dispose
(
false
);
this
.
Dispose
(
false
);
...
@@ -144,7 +143,7 @@ namespace ENet
...
@@ -144,7 +143,7 @@ namespace ENet
public
void
Stop
()
public
void
Stop
()
{
{
isRunning
=
false
;
this
.
isRunning
=
false
;
}
}
}
}
}
}
\ No newline at end of file
CSharp/Platform/ENet/NativeMethods.cs
浏览文件 @
b4cdeac0
...
@@ -23,10 +23,12 @@ namespace ENet
...
@@ -23,10 +23,12 @@ namespace ENet
internal
static
extern
int
enet_address_set_host
(
ref
ENetAddress
address
,
string
hostName
);
internal
static
extern
int
enet_address_set_host
(
ref
ENetAddress
address
,
string
hostName
);
[
DllImport
(
LIB
,
CallingConvention
=
CallingConvention
.
Cdecl
)]
[
DllImport
(
LIB
,
CallingConvention
=
CallingConvention
.
Cdecl
)]
internal
static
extern
int
enet_address_get_host
(
ref
ENetAddress
address
,
StringBuilder
hostName
,
uint
nameLength
);
internal
static
extern
int
enet_address_get_host
(
ref
ENetAddress
address
,
StringBuilder
hostName
,
uint
nameLength
);
[
DllImport
(
LIB
,
CallingConvention
=
CallingConvention
.
Cdecl
)]
[
DllImport
(
LIB
,
CallingConvention
=
CallingConvention
.
Cdecl
)]
internal
static
extern
int
enet_address_get_host_ip
(
ref
ENetAddress
address
,
StringBuilder
hostIp
,
uint
ipLength
);
internal
static
extern
int
enet_address_get_host_ip
(
ref
ENetAddress
address
,
StringBuilder
hostIp
,
uint
ipLength
);
[
DllImport
(
LIB
,
CallingConvention
=
CallingConvention
.
Cdecl
)]
[
DllImport
(
LIB
,
CallingConvention
=
CallingConvention
.
Cdecl
)]
internal
static
extern
void
enet_deinitialize
();
internal
static
extern
void
enet_deinitialize
();
...
@@ -45,17 +47,20 @@ namespace ENet
...
@@ -45,17 +47,20 @@ namespace ENet
[
DllImport
(
LIB
,
CallingConvention
=
CallingConvention
.
Cdecl
)]
[
DllImport
(
LIB
,
CallingConvention
=
CallingConvention
.
Cdecl
)]
internal
static
extern
IntPtr
enet_host_create
(
internal
static
extern
IntPtr
enet_host_create
(
ref
ENetAddress
address
,
uint
peerLimit
,
uint
channelLimit
,
uint
incomingBandwidth
,
uint
outgoingBandwidth
);
ref
ENetAddress
address
,
uint
peerLimit
,
uint
channelLimit
,
uint
incomingBandwidth
,
uint
outgoingBandwidth
);
[
DllImport
(
LIB
,
CallingConvention
=
CallingConvention
.
Cdecl
)]
[
DllImport
(
LIB
,
CallingConvention
=
CallingConvention
.
Cdecl
)]
internal
static
extern
IntPtr
enet_host_create
(
internal
static
extern
IntPtr
enet_host_create
(
IntPtr
address
,
uint
peerLimit
,
uint
channelLimit
,
uint
incomingBandwidth
,
uint
outgoingBandwidth
);
IntPtr
address
,
uint
peerLimit
,
uint
channelLimit
,
uint
incomingBandwidth
,
uint
outgoingBandwidth
);
[
DllImport
(
LIB
,
CallingConvention
=
CallingConvention
.
Cdecl
)]
[
DllImport
(
LIB
,
CallingConvention
=
CallingConvention
.
Cdecl
)]
internal
static
extern
void
enet_host_destroy
(
IntPtr
host
);
internal
static
extern
void
enet_host_destroy
(
IntPtr
host
);
[
DllImport
(
LIB
,
CallingConvention
=
CallingConvention
.
Cdecl
)]
[
DllImport
(
LIB
,
CallingConvention
=
CallingConvention
.
Cdecl
)]
internal
static
extern
IntPtr
enet_host_connect
(
IntPtr
host
,
ref
ENetAddress
address
,
uint
channelCount
,
uint
data
);
internal
static
extern
IntPtr
enet_host_connect
(
IntPtr
host
,
ref
ENetAddress
address
,
uint
channelCount
,
uint
data
);
[
DllImport
(
LIB
,
CallingConvention
=
CallingConvention
.
Cdecl
)]
[
DllImport
(
LIB
,
CallingConvention
=
CallingConvention
.
Cdecl
)]
internal
static
extern
void
enet_host_broadcast
(
IntPtr
host
,
byte
channelID
,
IntPtr
packet
);
internal
static
extern
void
enet_host_broadcast
(
IntPtr
host
,
byte
channelID
,
IntPtr
packet
);
...
@@ -67,7 +72,8 @@ namespace ENet
...
@@ -67,7 +72,8 @@ namespace ENet
internal
static
extern
void
enet_host_channel_limit
(
IntPtr
host
,
uint
channelLimit
);
internal
static
extern
void
enet_host_channel_limit
(
IntPtr
host
,
uint
channelLimit
);
[
DllImport
(
LIB
,
CallingConvention
=
CallingConvention
.
Cdecl
)]
[
DllImport
(
LIB
,
CallingConvention
=
CallingConvention
.
Cdecl
)]
internal
static
extern
void
enet_host_bandwidth_limit
(
IntPtr
host
,
uint
incomingBandwidth
,
uint
outgoingBandwidth
);
internal
static
extern
void
enet_host_bandwidth_limit
(
IntPtr
host
,
uint
incomingBandwidth
,
uint
outgoingBandwidth
);
[
DllImport
(
LIB
,
CallingConvention
=
CallingConvention
.
Cdecl
)]
[
DllImport
(
LIB
,
CallingConvention
=
CallingConvention
.
Cdecl
)]
internal
static
extern
void
enet_host_flush
(
IntPtr
host
);
internal
static
extern
void
enet_host_flush
(
IntPtr
host
);
...
@@ -85,7 +91,8 @@ namespace ENet
...
@@ -85,7 +91,8 @@ namespace ENet
internal
static
extern
void
enet_time_set
(
uint
newTimeBase
);
internal
static
extern
void
enet_time_set
(
uint
newTimeBase
);
[
DllImport
(
LIB
,
CallingConvention
=
CallingConvention
.
Cdecl
)]
[
DllImport
(
LIB
,
CallingConvention
=
CallingConvention
.
Cdecl
)]
internal
static
extern
IntPtr
enet_packet_create
(
byte
[]
data
,
uint
dataLength
,
PacketFlags
flags
);
internal
static
extern
IntPtr
enet_packet_create
(
byte
[]
data
,
uint
dataLength
,
PacketFlags
flags
);
[
DllImport
(
LIB
,
CallingConvention
=
CallingConvention
.
Cdecl
)]
[
DllImport
(
LIB
,
CallingConvention
=
CallingConvention
.
Cdecl
)]
internal
static
extern
void
enet_packet_destroy
(
IntPtr
packet
);
internal
static
extern
void
enet_packet_destroy
(
IntPtr
packet
);
...
...
CSharp/Platform/ENet/NativeStructs.cs
浏览文件 @
b4cdeac0
...
@@ -54,7 +54,9 @@ namespace ENet
...
@@ -54,7 +54,9 @@ namespace ENet
[
UnmanagedFunctionPointer
(
CallingConvention
.
Cdecl
)]
[
UnmanagedFunctionPointer
(
CallingConvention
.
Cdecl
)]
public
delegate
void
no_memory_cb
();
public
delegate
void
no_memory_cb
();
private
IntPtr
malloc
,
free
,
no_memory
;
private
readonly
IntPtr
malloc
;
private
readonly
IntPtr
free
;
private
readonly
IntPtr
no_memory
;
}
}
[
StructLayout
(
LayoutKind
.
Sequential
)]
[
StructLayout
(
LayoutKind
.
Sequential
)]
...
@@ -62,10 +64,12 @@ namespace ENet
...
@@ -62,10 +64,12 @@ namespace ENet
{
{
[
UnmanagedFunctionPointer
(
CallingConvention
.
Cdecl
)]
[
UnmanagedFunctionPointer
(
CallingConvention
.
Cdecl
)]
public
delegate
void
compress_cb
(
public
delegate
void
compress_cb
(
IntPtr
context
,
IntPtr
inBuffers
,
IntPtr
inBufferCount
,
IntPtr
inLimit
,
IntPtr
outData
,
IntPtr
outLimit
);
IntPtr
context
,
IntPtr
inBuffers
,
IntPtr
inBufferCount
,
IntPtr
inLimit
,
IntPtr
outData
,
IntPtr
outLimit
);
[
UnmanagedFunctionPointer
(
CallingConvention
.
Cdecl
)]
[
UnmanagedFunctionPointer
(
CallingConvention
.
Cdecl
)]
public
delegate
void
decompress_cb
(
IntPtr
context
,
IntPtr
inData
,
IntPtr
inLimit
,
IntPtr
outData
,
IntPtr
outLimit
);
public
delegate
void
decompress_cb
(
IntPtr
context
,
IntPtr
inData
,
IntPtr
inLimit
,
IntPtr
outData
,
IntPtr
outLimit
);
[
UnmanagedFunctionPointer
(
CallingConvention
.
Cdecl
)]
[
UnmanagedFunctionPointer
(
CallingConvention
.
Cdecl
)]
public
delegate
void
destroy_cb
(
IntPtr
context
);
public
delegate
void
destroy_cb
(
IntPtr
context
);
...
...
CSharp/Platform/ENet/Packet.cs
浏览文件 @
b4cdeac0
using
System
;
using
System
;
using
System.IO
;
using
System.Runtime.InteropServices
;
using
System.Runtime.InteropServices
;
using
Log
;
namespace
ENet
namespace
ENet
{
{
...
...
CSharp/Platform/ENet/Peer.cs
浏览文件 @
b4cdeac0
using
System
;
using
System
;
using
System.Runtime.InteropServices
;
using
System.Runtime.InteropServices
;
using
System.Threading.Tasks
;
using
System.Threading.Tasks
;
using
Log
;
namespace
ENet
namespace
ENet
{
{
...
...
CSharp/Platform/ENet/ServerHost.cs
浏览文件 @
b4cdeac0
using
System
;
using
System
;
using
System.Threading.Tasks
;
using
System.Threading.Tasks
;
using
Log
;
namespace
ENet
namespace
ENet
{
{
public
sealed
class
ServerHost
:
Host
public
sealed
class
ServerHost
:
Host
{
{
private
Action
<
Peer
>
acceptEvent
;
private
Action
<
Peer
>
acceptEvent
;
public
ServerHost
(
Address
address
,
public
ServerHost
(
uint
peerLimit
=
NativeMethods
.
ENET_PROTOCOL_MAXIMUM_PEER_ID
,
Address
address
,
uint
peerLimit
=
NativeMethods
.
ENET_PROTOCOL_MAXIMUM_PEER_ID
,
uint
channelLimit
=
0
,
uint
incom
ingBandwidth
=
0
,
uint
channelLimit
=
0
,
uint
incomingBandwidth
=
0
,
uint
outgo
ingBandwidth
=
0
,
uint
outgoingBandwidth
=
0
,
bool
enableCrc
=
true
)
bool
enableCrc
=
true
)
{
{
if
(
peerLimit
>
NativeMethods
.
ENET_PROTOCOL_MAXIMUM_PEER_ID
)
if
(
peerLimit
>
NativeMethods
.
ENET_PROTOCOL_MAXIMUM_PEER_ID
)
{
{
...
@@ -21,8 +20,8 @@ namespace ENet
...
@@ -21,8 +20,8 @@ namespace ENet
ENetAddress
nativeAddress
=
address
.
Struct
;
ENetAddress
nativeAddress
=
address
.
Struct
;
this
.
host
=
NativeMethods
.
enet_host_create
(
this
.
host
=
NativeMethods
.
enet_host_create
(
ref
nativeAddress
,
peerLimit
,
ref
nativeAddress
,
peerLimit
,
channelLimit
,
incomingBandwidth
,
channelLimit
,
incomingBandwidth
,
outgoingBandwidth
);
outgoingBandwidth
);
if
(
this
.
host
==
IntPtr
.
Zero
)
if
(
this
.
host
==
IntPtr
.
Zero
)
{
{
...
@@ -35,7 +34,7 @@ namespace ENet
...
@@ -35,7 +34,7 @@ namespace ENet
}
}
}
}
public
Task
<
Peer
>
AcceptAsync
()
public
Task
<
Peer
>
AcceptAsync
()
{
{
if
(
this
.
PeersManager
.
ContainsKey
(
IntPtr
.
Zero
))
if
(
this
.
PeersManager
.
ContainsKey
(
IntPtr
.
Zero
))
{
{
...
@@ -65,7 +64,7 @@ namespace ENet
...
@@ -65,7 +64,7 @@ namespace ENet
case
EventType
.
Connect
:
case
EventType
.
Connect
:
{
{
var
peer
=
this
.
PeersManager
[
IntPtr
.
Zero
];
var
peer
=
this
.
PeersManager
[
IntPtr
.
Zero
];
this
.
PeersManager
.
Remove
(
IntPtr
.
Zero
);
this
.
PeersManager
.
Remove
(
IntPtr
.
Zero
);
peer
.
PeerPtr
=
ev
.
PeerPtr
;
peer
.
PeerPtr
=
ev
.
PeerPtr
;
...
@@ -92,7 +91,7 @@ namespace ENet
...
@@ -92,7 +91,7 @@ namespace ENet
this
.
PeersManager
.
Remove
(
ev
.
PeerPtr
);
this
.
PeersManager
.
Remove
(
ev
.
PeerPtr
);
// enet_peer_disconnect 会 reset Peer,这里设置为0,防止再次Dispose
// enet_peer_disconnect 会 reset Peer,这里设置为0,防止再次Dispose
peer
.
PeerPtr
=
IntPtr
.
Zero
;
peer
.
PeerPtr
=
IntPtr
.
Zero
;
if
(
peerEvent
.
Received
!=
null
)
if
(
peerEvent
.
Received
!=
null
)
{
{
peerEvent
.
OnReceived
(
ev
);
peerEvent
.
OnReceived
(
ev
);
...
@@ -109,9 +108,9 @@ namespace ENet
...
@@ -109,9 +108,9 @@ namespace ENet
public
void
Start
(
int
timeout
=
0
)
public
void
Start
(
int
timeout
=
0
)
{
{
while
(
isRunning
)
while
(
this
.
isRunning
)
{
{
RunOnce
(
timeout
);
this
.
RunOnce
(
timeout
);
}
}
}
}
}
}
...
...
CSharp/Platform/ENetTest/ENetClientServerTest.cs
浏览文件 @
b4cdeac0
...
@@ -24,7 +24,7 @@ namespace ENetCSTest
...
@@ -24,7 +24,7 @@ namespace ENetCSTest
}
}
await
peer
.
DisconnectAsync
();
await
peer
.
DisconnectAsync
();
host
.
Stop
();
host
.
Stop
();
}
}
...
@@ -75,4 +75,4 @@ namespace ENetCSTest
...
@@ -75,4 +75,4 @@ namespace ENetCSTest
clientThread
.
Join
();
clientThread
.
Join
();
}
}
}
}
}
}
\ No newline at end of file
CSharp/Platform/ENetTest/Properties/AssemblyInfo.cs
浏览文件 @
b4cdeac0
using
System.Reflection
;
using
System.Reflection
;
using
System.Runtime.CompilerServices
;
using
System.Runtime.InteropServices
;
using
System.Runtime.InteropServices
;
// 有关程序集的常规信息通过以下特性集
// 有关程序集的常规信息通过以下特性集
// 控制。更改这些特性值可修改
// 控制。更改这些特性值可修改
// 与程序集关联的信息。
// 与程序集关联的信息。
[
assembly
:
AssemblyTitle
(
"ENetCSTest"
)]
[
assembly
:
AssemblyTitle
(
"ENetCSTest"
)]
[
assembly
:
AssemblyDescription
(
""
)]
[
assembly
:
AssemblyDescription
(
""
)]
[
assembly
:
AssemblyConfiguration
(
""
)]
[
assembly
:
AssemblyConfiguration
(
""
)]
...
@@ -17,9 +17,11 @@ using System.Runtime.InteropServices;
...
@@ -17,9 +17,11 @@ using System.Runtime.InteropServices;
// 将 ComVisible 设置为 false 会使此程序集中的类型
// 将 ComVisible 设置为 false 会使此程序集中的类型
// 对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型,
// 对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型,
// 请将该类型上的 ComVisible 特性设置为 true。
// 请将该类型上的 ComVisible 特性设置为 true。
[
assembly
:
ComVisible
(
false
)]
[
assembly
:
ComVisible
(
false
)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[
assembly
:
Guid
(
"b52f4804-3f6e-4268-810a-08fe8ca12bd0"
)]
[
assembly
:
Guid
(
"b52f4804-3f6e-4268-810a-08fe8ca12bd0"
)]
// 程序集的版本信息由以下四个值组成:
// 程序集的版本信息由以下四个值组成:
...
@@ -32,5 +34,6 @@ using System.Runtime.InteropServices;
...
@@ -32,5 +34,6 @@ using System.Runtime.InteropServices;
// 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
// 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
// 方法是按如下所示使用“*”:
// 方法是按如下所示使用“*”:
// [assembly: AssemblyVersion("1.0.*")]
// [assembly: AssemblyVersion("1.0.*")]
[
assembly
:
AssemblyVersion
(
"1.0.0.0"
)]
[
assembly
:
AssemblyVersion
(
"1.0.0.0"
)]
[
assembly
:
AssemblyFileVersion
(
"1.0.0.0"
)]
[
assembly
:
AssemblyFileVersion
(
"1.0.0.0"
)]
\ No newline at end of file
CSharp/Platform/Helper/ByteHelper.cs
浏览文件 @
b4cdeac0
using
System
;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
System.Globalization
;
using
System.Globalization
;
using
System.Text
;
using
System.Text
;
...
@@ -9,12 +8,12 @@ namespace Helper
...
@@ -9,12 +8,12 @@ namespace Helper
{
{
public
static
string
ToHex
(
this
byte
b
)
public
static
string
ToHex
(
this
byte
b
)
{
{
return
b
.
ToString
(
"X2"
);
return
b
.
ToString
(
"X2"
);
}
}
public
static
string
ToHex
(
this
IEnumerable
<
byte
>
bytes
)
public
static
string
ToHex
(
this
IEnumerable
<
byte
>
bytes
)
{
{
var
stringBuilder
=
new
StringBuilder
();
var
stringBuilder
=
new
StringBuilder
();
foreach
(
byte
b
in
bytes
)
foreach
(
byte
b
in
bytes
)
{
{
stringBuilder
.
Append
(
b
.
ToString
(
"X2"
));
stringBuilder
.
Append
(
b
.
ToString
(
"X2"
));
...
@@ -32,4 +31,4 @@ namespace Helper
...
@@ -32,4 +31,4 @@ namespace Helper
return
stringBuilder
.
ToString
();
return
stringBuilder
.
ToString
();
}
}
}
}
}
}
\ No newline at end of file
CSharp/Platform/Helper/JsonHelper.cs
浏览文件 @
b4cdeac0
using
System
;
using
System.IO
;
using
System.Collections.Generic
;
using
System.Runtime.Serialization.Json
;
using
System.IO
;
using
System.Linq
;
using
System.Text
;
using
System.Text
;
using
System.Threading.Tasks
;
using
System.Runtime.Serialization.Json
;
namespace
Helper
namespace
Helper
{
{
...
@@ -12,7 +8,7 @@ namespace Helper
...
@@ -12,7 +8,7 @@ namespace Helper
{
{
public
static
string
ToString
<
T
>(
T
obj
)
public
static
string
ToString
<
T
>(
T
obj
)
{
{
var
serializer
=
new
DataContractJsonSerializer
(
typeof
(
T
));
var
serializer
=
new
DataContractJsonSerializer
(
typeof
(
T
));
using
(
var
ms
=
new
MemoryStream
())
using
(
var
ms
=
new
MemoryStream
())
{
{
serializer
.
WriteObject
(
ms
,
obj
);
serializer
.
WriteObject
(
ms
,
obj
);
...
@@ -23,12 +19,12 @@ namespace Helper
...
@@ -23,12 +19,12 @@ namespace Helper
public
static
T
FromString
<
T
>(
string
str
)
public
static
T
FromString
<
T
>(
string
str
)
{
{
var
serializer
=
new
DataContractJsonSerializer
(
typeof
(
T
));
var
serializer
=
new
DataContractJsonSerializer
(
typeof
(
T
));
using
(
var
ms
=
new
MemoryStream
(
Encoding
.
Default
.
GetBytes
(
str
)))
using
(
var
ms
=
new
MemoryStream
(
Encoding
.
Default
.
GetBytes
(
str
)))
{
{
var
obj
=
(
T
)
serializer
.
ReadObject
(
ms
);
var
obj
=
(
T
)
serializer
.
ReadObject
(
ms
);
return
obj
;
return
obj
;
}
}
}
}
}
}
}
}
\ No newline at end of file
CSharp/Platform/Helper/LoaderHelper.cs
浏览文件 @
b4cdeac0
using
System
;
using
System.IO
;
using
System.Collections.Generic
;
using
System.IO
;
using
System.Reflection
;
using
System.Reflection
;
namespace
Helper
namespace
Helper
...
@@ -14,4 +12,4 @@ namespace Helper
...
@@ -14,4 +12,4 @@ namespace Helper
return
assembly
;
return
assembly
;
}
}
}
}
}
}
\ No newline at end of file
CSharp/Platform/Helper/Properties/AssemblyInfo.cs
浏览文件 @
b4cdeac0
using
System.Reflection
;
using
System.Reflection
;
using
System.Runtime.CompilerServices
;
using
System.Runtime.InteropServices
;
using
System.Runtime.InteropServices
;
// 有关程序集的常规信息通过以下
// 有关程序集的常规信息通过以下
// 特性集控制。更改这些特性值可修改
// 特性集控制。更改这些特性值可修改
// 与程序集关联的信息。
// 与程序集关联的信息。
[
assembly
:
AssemblyTitle
(
"Helper"
)]
[
assembly
:
AssemblyTitle
(
"Helper"
)]
[
assembly
:
AssemblyDescription
(
""
)]
[
assembly
:
AssemblyDescription
(
""
)]
[
assembly
:
AssemblyConfiguration
(
""
)]
[
assembly
:
AssemblyConfiguration
(
""
)]
...
@@ -17,9 +17,11 @@ using System.Runtime.InteropServices;
...
@@ -17,9 +17,11 @@ using System.Runtime.InteropServices;
// 将 ComVisible 设置为 false 使此程序集中的类型
// 将 ComVisible 设置为 false 使此程序集中的类型
// 对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型,
// 对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型,
// 则将该类型上的 ComVisible 特性设置为 true。
// 则将该类型上的 ComVisible 特性设置为 true。
[
assembly
:
ComVisible
(
false
)]
[
assembly
:
ComVisible
(
false
)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[
assembly
:
Guid
(
"cfce4237-03ff-4f48-9213-aac7ddc7f15e"
)]
[
assembly
:
Guid
(
"cfce4237-03ff-4f48-9213-aac7ddc7f15e"
)]
// 程序集的版本信息由下面四个值组成:
// 程序集的版本信息由下面四个值组成:
...
@@ -32,5 +34,6 @@ using System.Runtime.InteropServices;
...
@@ -32,5 +34,6 @@ using System.Runtime.InteropServices;
// 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
// 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
// 方法是按如下所示使用“*”:
// 方法是按如下所示使用“*”:
// [assembly: AssemblyVersion("1.0.*")]
// [assembly: AssemblyVersion("1.0.*")]
[
assembly
:
AssemblyVersion
(
"1.0.0.0"
)]
[
assembly
:
AssemblyVersion
(
"1.0.0.0"
)]
[
assembly
:
AssemblyFileVersion
(
"1.0.0.0"
)]
[
assembly
:
AssemblyFileVersion
(
"1.0.0.0"
)]
\ No newline at end of file
CSharp/Platform/Helper/ProtobufHelper.cs
浏览文件 @
b4cdeac0
...
@@ -18,4 +18,4 @@ namespace Helper
...
@@ -18,4 +18,4 @@ namespace Helper
return
Serializer
.
Deserialize
<
T
>(
ms
);
return
Serializer
.
Deserialize
<
T
>(
ms
);
}
}
}
}
}
}
\ No newline at end of file
CSharp/Platform/Helper/StringHelper.cs
浏览文件 @
b4cdeac0
...
@@ -17,4 +17,4 @@ namespace Helper
...
@@ -17,4 +17,4 @@ namespace Helper
return
byteArray
;
return
byteArray
;
}
}
}
}
}
}
\ No newline at end of file
CSharp/Platform/Helper/XmlHelper.cs
浏览文件 @
b4cdeac0
...
@@ -6,15 +6,15 @@ using System.Xml.Serialization;
...
@@ -6,15 +6,15 @@ using System.Xml.Serialization;
namespace
Helper
namespace
Helper
{
{
public
static
class
XmlHelper
public
static
class
XmlHelper
{
{
/// <summary>
/// <summary>
/// 对象序列化成 XML String
/// 对象序列化成 XML String
/// </summary>
/// </summary>
public
static
string
XmlSerialize
<
T
>(
T
obj
)
public
static
string
XmlSerialize
<
T
>(
T
obj
)
{
{
string
xmlString
=
string
.
Empty
;
string
xmlString
=
string
.
Empty
;
var
xmlSerializer
=
new
XmlSerializer
(
typeof
(
T
));
var
xmlSerializer
=
new
XmlSerializer
(
typeof
(
T
));
using
(
var
ms
=
new
MemoryStream
())
using
(
var
ms
=
new
MemoryStream
())
{
{
xmlSerializer
.
Serialize
(
ms
,
obj
);
xmlSerializer
.
Serialize
(
ms
,
obj
);
...
@@ -29,14 +29,14 @@ namespace Helper
...
@@ -29,14 +29,14 @@ namespace Helper
public
static
T
XmlDeserialize
<
T
>(
string
xmlString
)
public
static
T
XmlDeserialize
<
T
>(
string
xmlString
)
{
{
T
t
=
default
(
T
);
T
t
=
default
(
T
);
var
xmlSerializer
=
new
XmlSerializer
(
typeof
(
T
));
var
xmlSerializer
=
new
XmlSerializer
(
typeof
(
T
));
Stream
xmlStream
=
new
MemoryStream
(
Encoding
.
UTF8
.
GetBytes
(
xmlString
));
Stream
xmlStream
=
new
MemoryStream
(
Encoding
.
UTF8
.
GetBytes
(
xmlString
));
using
(
var
xmlReader
=
XmlReader
.
Create
(
xmlStream
))
using
(
var
xmlReader
=
XmlReader
.
Create
(
xmlStream
))
{
{
Object
obj
=
xmlSerializer
.
Deserialize
(
xmlReader
);
Object
obj
=
xmlSerializer
.
Deserialize
(
xmlReader
);
t
=
(
T
)
obj
;
t
=
(
T
)
obj
;
}
}
return
t
;
return
t
;
}
}
}
}
}
}
\ No newline at end of file
CSharp/Platform/Hooks/RecvHook.cs
浏览文件 @
b4cdeac0
...
@@ -5,7 +5,8 @@ using Log;
...
@@ -5,7 +5,8 @@ using Log;
namespace
Hooks
namespace
Hooks
{
{
[
UnmanagedFunctionPointer
(
CallingConvention
.
StdCall
,
CharSet
=
CharSet
.
Unicode
,
SetLastError
=
true
)]
[
UnmanagedFunctionPointer
(
CallingConvention
.
StdCall
,
CharSet
=
CharSet
.
Unicode
,
SetLastError
=
true
)]
public
delegate
int
DRecv
(
IntPtr
handle
,
IntPtr
buf
,
int
count
,
int
flag
);
public
delegate
int
DRecv
(
IntPtr
handle
,
IntPtr
buf
,
int
count
,
int
flag
);
public
class
RecvHook
:
IDisposable
public
class
RecvHook
:
IDisposable
...
@@ -19,7 +20,8 @@ namespace Hooks
...
@@ -19,7 +20,8 @@ namespace Hooks
{
{
try
try
{
{
this
.
localHook
=
LocalHook
.
Create
(
LocalHook
.
GetProcAddress
(
"Ws2_32.dll"
,
"recv"
),
new
DRecv
(
dRecv
),
this
);
this
.
localHook
=
LocalHook
.
Create
(
LocalHook
.
GetProcAddress
(
"Ws2_32.dll"
,
"recv"
),
new
DRecv
(
dRecv
),
this
);
this
.
localHook
.
ThreadACL
.
SetInclusiveACL
(
new
[]
{
0
});
this
.
localHook
.
ThreadACL
.
SetInclusiveACL
(
new
[]
{
0
});
}
}
catch
(
Exception
)
catch
(
Exception
)
...
...
CSharp/Platform/Hooks/SendHook.cs
浏览文件 @
b4cdeac0
...
@@ -5,7 +5,8 @@ using Log;
...
@@ -5,7 +5,8 @@ using Log;
namespace
Hooks
namespace
Hooks
{
{
[
UnmanagedFunctionPointer
(
CallingConvention
.
StdCall
,
CharSet
=
CharSet
.
Unicode
,
SetLastError
=
true
)]
[
UnmanagedFunctionPointer
(
CallingConvention
.
StdCall
,
CharSet
=
CharSet
.
Unicode
,
SetLastError
=
true
)]
public
delegate
int
DSend
(
IntPtr
handle
,
IntPtr
buf
,
int
count
,
int
flag
);
public
delegate
int
DSend
(
IntPtr
handle
,
IntPtr
buf
,
int
count
,
int
flag
);
public
class
SendHook
:
IDisposable
public
class
SendHook
:
IDisposable
...
@@ -19,7 +20,8 @@ namespace Hooks
...
@@ -19,7 +20,8 @@ namespace Hooks
{
{
try
try
{
{
this
.
localHook
=
LocalHook
.
Create
(
LocalHook
.
GetProcAddress
(
"Ws2_32.dll"
,
"send"
),
new
DSend
(
dSend
),
this
);
this
.
localHook
=
LocalHook
.
Create
(
LocalHook
.
GetProcAddress
(
"Ws2_32.dll"
,
"send"
),
new
DSend
(
dSend
),
this
);
this
.
localHook
.
ThreadACL
.
SetInclusiveACL
(
new
[]
{
0
});
this
.
localHook
.
ThreadACL
.
SetInclusiveACL
(
new
[]
{
0
});
}
}
catch
(
Exception
)
catch
(
Exception
)
...
...
CSharp/Platform/Log/StackInfoDecorater.cs
浏览文件 @
b4cdeac0
...
@@ -11,17 +11,9 @@ namespace Log
...
@@ -11,17 +11,9 @@ namespace Log
this
.
FileLineNumber
=
true
;
this
.
FileLineNumber
=
true
;
}
}
public
bool
FileName
public
bool
FileName
{
get
;
set
;
}
{
get
;
set
;
}
public
bool
FileLineNumber
public
bool
FileLineNumber
{
get
;
set
;
}
{
get
;
set
;
}
public
override
string
Decorate
(
string
message
)
public
override
string
Decorate
(
string
message
)
{
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录