Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
guo450212436
et
提交
e041e2b7
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,发现更多精彩内容 >>
提交
e041e2b7
编写于
11月 11, 2016
作者:
T
tanghai
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
1.Object增加ToString方法,使用MongoHelper.ToJson实现,方便打印对象
2.删除订阅Server Log功能
上级
d4d39b7b
变更
13
隐藏空白更改
内联
并排
Showing
13 changed file
with
64 addition
and
151 deletion
+64
-151
Server/Base/Log.cs
Server/Base/Log.cs
+1
-18
Server/Controller/Message/C2R_SubscribeLogHandler.cs
Server/Controller/Message/C2R_SubscribeLogHandler.cs
+0
-19
Server/Controller/Server.Controller.csproj
Server/Controller/Server.Controller.csproj
+0
-1
Server/Model/Component/LogToClientComponent.cs
Server/Model/Component/LogToClientComponent.cs
+0
-48
Server/Model/Server.Model.csproj
Server/Model/Server.Model.csproj
+0
-1
Unity/Assets/Editor/ClientConfigEditor/ClientConfigEditor.cs
Unity/Assets/Editor/ClientConfigEditor/ClientConfigEditor.cs
+1
-1
Unity/Assets/Scripts/Component/BenchmakComponent.cs
Unity/Assets/Scripts/Component/BenchmakComponent.cs
+22
-19
Unity/Assets/Scripts/Entity/Config/StartConfig.cs
Unity/Assets/Scripts/Entity/Config/StartConfig.cs
+0
-5
Unity/Assets/Scripts/Entity/Message/Message.cs
Unity/Assets/Scripts/Entity/Message/Message.cs
+9
-22
Unity/Assets/Scripts/Message/AMessage.cs
Unity/Assets/Scripts/Message/AMessage.cs
+4
-1
Unity/Assets/Scripts/Object/Component.cs
Unity/Assets/Scripts/Object/Component.cs
+8
-3
Unity/Assets/Scripts/Object/Entity.cs
Unity/Assets/Scripts/Object/Entity.cs
+5
-1
Unity/Assets/Scripts/Object/Object.cs
Unity/Assets/Scripts/Object/Object.cs
+14
-12
未找到文件。
Server/Base/Log.cs
浏览文件 @
e041e2b7
using
System
;
using
System.Collections.Generic
;
namespace
Base
namespace
Base
{
public
static
class
Log
{
private
static
readonly
ILog
globalLog
=
new
NLogAdapter
();
public
static
Dictionary
<
long
,
Action
<
LogType
,
string
>>
Callback
{
get
;
}
=
new
Dictionary
<
long
,
Action
<
LogType
,
string
>>();
private
static
void
OnCallback
(
LogType
type
,
string
message
)
{
foreach
(
var
action
in
Callback
.
Values
)
{
action
(
type
,
message
);
}
}
public
static
void
Warning
(
string
message
)
{
globalLog
.
Warning
(
message
);
OnCallback
(
LogType
.
Warning
,
message
);
}
public
static
void
Info
(
string
message
)
{
globalLog
.
Info
(
message
);
OnCallback
(
LogType
.
Info
,
message
);
}
public
static
void
Debug
(
string
message
)
{
globalLog
.
Debug
(
message
);
OnCallback
(
LogType
.
Debug
,
message
);
}
public
static
void
Error
(
string
message
)
{
globalLog
.
Error
(
message
);
OnCallback
(
LogType
.
Error
,
message
);
}
}
}
Server/Controller/Message/C2R_SubscribeLogHandler.cs
已删除
100644 → 0
浏览文件 @
d4d39b7b
using
System
;
using
Base
;
using
Model
;
namespace
Controller
{
[
MessageHandler
(
AppType
.
Realm
)]
public
class
C2R_SubscribeLogHandler
:
AMRpcHandler
<
C2R_SubscribeLog
,
R2C_SubscribeLog
>
{
protected
override
void
Run
(
Session
session
,
C2R_SubscribeLog
message
,
Action
<
R2C_SubscribeLog
>
reply
)
{
Log
.
Info
(
MongoHelper
.
ToJson
(
message
));
//entity.AddComponent<LogToClientComponent>();
reply
(
new
R2C_SubscribeLog
());
}
}
}
\ No newline at end of file
Server/Controller/Server.Controller.csproj
浏览文件 @
e041e2b7
...
...
@@ -39,7 +39,6 @@
<Compile
Include=
"Message\M2A_ReloadHandler.cs"
/>
<Compile
Include=
"Message\C2M_ReloadHandler.cs"
/>
<Compile
Include=
"Message\R2G_GetLoginKeyHandler.cs"
/>
<Compile
Include=
"Message\C2R_SubscribeLogHandler.cs"
/>
<Compile
Include=
"Properties\AssemblyInfo.cs"
/>
<Compile
Include=
"Message\C2R_LoginHandler.cs"
/>
</ItemGroup>
...
...
Server/Model/Component/LogToClientComponent.cs
已删除
100644 → 0
浏览文件 @
d4d39b7b
using
Base
;
namespace
Model
{
[
ObjectEvent
]
public
class
LogToClientComponentEvent
:
ObjectEvent
<
LogToClientComponent
>,
IAwake
{
public
void
Awake
()
{
this
.
GetValue
().
Awake
();
}
}
public
class
LogToClientComponent
:
Component
{
private
AppType
appType
;
private
int
appId
;
public
void
Awake
()
{
this
.
appType
=
Game
.
Scene
.
GetComponent
<
StartConfigComponent
>().
MyConfig
.
AppType
;
this
.
appId
=
Game
.
Scene
.
GetComponent
<
StartConfigComponent
>().
MyConfig
.
AppId
;
Log
.
Callback
.
Add
(
this
.
Id
,
this
.
LogToClient
);
}
private
void
LogToClient
(
LogType
type
,
string
message
)
{
if
(
this
.
Owner
.
Id
==
0
)
{
return
;
}
this
.
GetOwner
<
Session
>().
Send
(
new
R2C_ServerLog
{
AppType
=
this
.
appType
,
AppId
=
this
.
appId
,
Type
=
type
,
Log
=
message
});
}
public
override
void
Dispose
()
{
if
(
this
.
Id
==
0
)
{
return
;
}
long
id
=
this
.
Id
;
base
.
Dispose
();
Log
.
Callback
.
Remove
(
id
);
}
}
}
Server/Model/Server.Model.csproj
浏览文件 @
e041e2b7
...
...
@@ -189,7 +189,6 @@
<Link>
Other\Options.cs
</Link>
</Compile>
<Compile
Include=
"Component\AppManagerComponent.cs"
/>
<Compile
Include=
"Component\LogToClientComponent.cs"
/>
<Compile
Include=
"Component\GateSessionKeyComponent.cs"
/>
<Compile
Include=
"Component\RealmGateAddressComponent.cs"
/>
<Compile
Include=
"Component\StartConfigComponent.cs"
/>
...
...
Unity/Assets/Editor/ClientConfigEditor/ClientConfigEditor.cs
浏览文件 @
e041e2b7
...
...
@@ -43,7 +43,7 @@ namespace MyEditor
{
using
(
StreamWriter
sw
=
new
StreamWriter
(
new
FileStream
(
Path
,
FileMode
.
Create
)))
{
sw
.
Write
(
MongoHelper
.
ToJson
(
this
.
config
)
);
sw
.
Write
(
this
.
config
);
}
}
}
...
...
Unity/Assets/Scripts/Component/BenchmakComponent.cs
浏览文件 @
e041e2b7
...
...
@@ -17,7 +17,7 @@ namespace Model
{
private
int
k
;
private
long
time1
=
TimeHelper
.
ClientNow
Ticks
();
private
long
time1
=
TimeHelper
.
ClientNow
();
public
async
void
Awake
(
string
address
)
{
...
...
@@ -32,35 +32,38 @@ namespace Model
private
async
void
TestAsync
(
NetOuterComponent
networkComponent
,
string
address
,
int
j
)
{
using
(
Session
session
=
networkComponent
.
Create
(
address
))
try
{
int
i
=
0
;
while
(
i
<
10000000
)
using
(
Session
session
=
networkComponent
.
Create
(
address
))
{
++
i
;
try
int
i
=
0
;
while
(
i
<
10000000
)
{
++
i
;
await
session
.
Call
<
C2R_Ping
,
R2C_Ping
>(
new
C2R_Ping
());
++
this
.
k
;
if
(
this
.
k
%
100000
==
0
)
if
(
this
.
k
%
100000
!=
0
)
{
long
time2
=
TimeHelper
.
ClientNowTicks
();
long
time
=
time2
-
this
.
time1
;
this
.
time1
=
time2
;
Log
.
Info
(
$"
{
j
}
Benchmark k:
{
k
}
每10W次耗时:
{
time
}
"
);
continue
;
}
}
catch
(
RpcException
e
)
{
Log
.
Error
(
e
.
ToString
());
}
catch
(
Exception
e
)
{
Log
.
Error
(
e
.
ToString
());
long
time2
=
TimeHelper
.
ClientNow
();
long
time
=
time2
-
this
.
time1
;
this
.
time1
=
time2
;
Log
.
Info
(
$"
{
j
}
Benchmark k:
{
this
.
k
}
每10W次耗时:
{
time
}
ms"
);
}
}
}
catch
(
RpcException
e
)
{
Log
.
Error
(
e
.
ToString
());
}
catch
(
Exception
e
)
{
Log
.
Error
(
e
.
ToString
());
}
}
public
override
void
Dispose
()
...
...
Unity/Assets/Scripts/Entity/Config/StartConfig.cs
浏览文件 @
e041e2b7
...
...
@@ -16,10 +16,5 @@ namespace Model
public
StartConfig
():
base
(
EntityType
.
Config
)
{
}
public
object
Clone
()
{
return
MongoHelper
.
FromJson
<
StartConfig
>(
MongoHelper
.
ToJson
(
this
));
}
}
}
Unity/Assets/Scripts/Entity/Message/Message.cs
浏览文件 @
e041e2b7
using
System.Collections.Generic
;
using
Base
;
using
MongoDB.Bson.Serialization.Attributes
;
...
...
@@ -8,9 +7,9 @@ namespace Model
[
BsonIgnoreExtraElements
]
public
class
C2R_Login
:
ARequest
{
[
BsonElement
(
"
a
"
)]
[
BsonElement
(
"
A
"
)]
public
string
Account
;
[
BsonElement
(
"
p
"
)]
[
BsonElement
(
"
P
"
)]
public
string
Password
;
}
...
...
@@ -18,9 +17,9 @@ namespace Model
[
BsonIgnoreExtraElements
]
public
class
R2C_Login
:
AResponse
{
[
BsonElement
(
"
a
"
)]
[
BsonElement
(
"
A
"
)]
public
string
Address
{
get
;
set
;
}
[
BsonElement
(
"
k
"
)]
[
BsonElement
(
"
K
"
)]
public
long
Key
{
get
;
set
;
}
}
...
...
@@ -28,28 +27,16 @@ namespace Model
[
BsonIgnoreExtraElements
]
public
class
R2C_ServerLog
:
AMessage
{
[
BsonElement
(
"
at
"
)]
[
BsonElement
(
"
AT
"
)]
public
AppType
AppType
{
get
;
set
;
}
[
BsonElement
(
"
a
"
)]
[
BsonElement
(
"
A
"
)]
public
int
AppId
{
get
;
set
;
}
[
BsonElement
(
"
t
"
)]
[
BsonElement
(
"
T
"
)]
public
LogType
Type
{
get
;
set
;
}
[
BsonElement
(
"
l
"
)]
[
BsonElement
(
"
L
"
)]
public
string
Log
{
get
;
set
;
}
}
[
Message
(
4
)]
[
BsonIgnoreExtraElements
]
public
class
C2R_SubscribeLog
:
ARequest
{
}
[
Message
(
5
)]
[
BsonIgnoreExtraElements
]
public
class
R2C_SubscribeLog
:
AResponse
{
}
[
Message
(
6
)]
[
BsonIgnoreExtraElements
]
public
class
R2G_GetLoginKey
:
ARequest
...
...
@@ -72,7 +59,7 @@ namespace Model
[
BsonIgnoreExtraElements
]
public
class
C2G_LoginGate
:
ARequest
{
[
BsonElement
(
"
k
"
)]
[
BsonElement
(
"
K
"
)]
public
long
Key
;
public
C2G_LoginGate
(
long
key
)
...
...
Unity/Assets/Scripts/Message/AMessage.cs
浏览文件 @
e041e2b7
namespace
Model
{
public
abstract
class
AMessage
public
abstract
class
AMessage
:
Object
{
protected
AMessage
():
base
(
0
)
{
}
}
public
abstract
class
ARequest
:
AMessage
...
...
Unity/Assets/Scripts/Object/Component.cs
浏览文件 @
e041e2b7
using
MongoDB.Bson.Serialization.Attributes
;
using
System
;
using
MongoDB.Bson.Serialization.Attributes
;
namespace
Model
{
[
BsonKnownTypes
(
typeof
(
AConfigComponent
))]
public
abstract
class
Component
:
Object
public
abstract
class
Component
:
Object
,
IDisposable
{
[
BsonIgnore
]
public
Entity
Owner
{
get
;
set
;
}
...
...
@@ -15,10 +16,12 @@ namespace Model
protected
Component
()
{
ObjectManager
.
Instance
.
Add
(
this
);
}
protected
Component
(
long
id
):
base
(
id
)
{
ObjectManager
.
Instance
.
Add
(
this
);
}
protected
T
GetComponent
<
T
>()
where
T
:
Component
...
...
@@ -32,8 +35,10 @@ namespace Model
{
return
;
}
base
.
Dispose
();
ObjectManager
.
Instance
.
Remove
(
this
);
}
}
}
\ No newline at end of file
Unity/Assets/Scripts/Object/Entity.cs
浏览文件 @
e041e2b7
...
...
@@ -20,11 +20,13 @@ namespace Model
protected
Entity
(
EntityType
entityType
)
{
this
.
Type
=
entityType
;
ObjectManager
.
Instance
.
Add
(
this
);
}
protected
Entity
(
long
id
,
EntityType
entityType
)
:
base
(
id
)
{
this
.
Type
=
entityType
;
ObjectManager
.
Instance
.
Add
(
this
);
}
public
override
void
Dispose
()
...
...
@@ -33,7 +35,7 @@ namespace Model
{
return
;
}
base
.
Dispose
();
foreach
(
Component
component
in
this
.
GetComponents
())
...
...
@@ -47,6 +49,8 @@ namespace Model
Log
.
Error
(
e
.
ToString
());
}
}
ObjectManager
.
Instance
.
Remove
(
this
);
}
public
K
AddComponent
<
K
>()
where
K
:
Component
,
new
()
...
...
Unity/Assets/Scripts/Object/Object.cs
浏览文件 @
e041e2b7
...
...
@@ -5,41 +5,43 @@ using MongoDB.Bson.Serialization.Attributes;
namespace
Model
{
public
abstract
class
Object
:
IDisposable
,
ISupportInitialize
public
abstract
class
Object
:
IDisposable
,
ISupportInitialize
,
ICloneable
{
[
BsonId
]
[
BsonIgnoreIfDefault
]
public
long
Id
{
get
;
private
set
;
}
protected
Object
()
{
Id
=
IdGenerater
.
GenerateId
();
ObjectManager
.
Instance
.
Add
(
this
);
}
protected
Object
(
long
id
)
{
this
.
Id
=
id
;
ObjectManager
.
Instance
.
Add
(
this
);
}
public
virtual
void
Dispose
()
public
virtual
void
BeginInit
()
{
if
(
this
.
Id
==
0
)
{
return
;
}
}
ObjectManager
.
Instance
.
Remove
(
this
);
public
virtual
void
EndInit
()
{
}
this
.
Id
=
0
;
public
override
string
ToString
()
{
return
MongoHelper
.
ToJson
(
this
);
}
public
virtual
void
BeginInit
()
public
virtual
void
Dispose
()
{
this
.
Id
=
0
;
}
public
virtual
void
EndInit
()
public
object
Clone
()
{
return
MongoHelper
.
FromJson
(
this
.
GetType
(),
this
.
ToString
());
}
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录