Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
老鱼er
et
提交
fd0b276f
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,发现更多精彩内容 >>
提交
fd0b276f
编写于
10月 19, 2016
作者:
T
tanghai
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Client连接Realm(验证服务器), Realm随机分配一个Gate,并且向Gate请求一个Key,发回给Client, client拿着key连接Gate
调试通过!
上级
fe94aadc
变更
25
隐藏空白更改
内联
并排
Showing
25 changed file
with
295 addition
and
50 deletion
+295
-50
Server/App/Program.cs
Server/App/Program.cs
+2
-0
Server/Controller/C2S_SubscribeLogHandler.cs
Server/Controller/C2S_SubscribeLogHandler.cs
+0
-19
Server/Controller/Message/C2G_LoginGateHandler.cs
Server/Controller/Message/C2G_LoginGateHandler.cs
+22
-0
Server/Controller/Message/C2R_LoginHandler.cs
Server/Controller/Message/C2R_LoginHandler.cs
+31
-0
Server/Controller/Message/C2R_SubscribeLogHandler.cs
Server/Controller/Message/C2R_SubscribeLogHandler.cs
+19
-0
Server/Controller/Message/R2G_GetLoginKeyHandler.cs
Server/Controller/Message/R2G_GetLoginKeyHandler.cs
+17
-0
Server/Controller/Server.Controller.csproj
Server/Controller/Server.Controller.csproj
+4
-2
Server/Model/Component/GateSessionKeyComponent.cs
Server/Model/Component/GateSessionKeyComponent.cs
+55
-0
Server/Model/Component/LogToClientComponent.cs
Server/Model/Component/LogToClientComponent.cs
+3
-1
Server/Model/Component/RealmGateAddressComponent.cs
Server/Model/Component/RealmGateAddressComponent.cs
+41
-0
Server/Model/Server.Model.csproj
Server/Model/Server.Model.csproj
+5
-0
Unity/Assets/Editor/ServerCommandLineEditor/UI/ServerCommandLineEditor.cs
...tor/ServerCommandLineEditor/UI/ServerCommandLineEditor.cs
+1
-0
Unity/Assets/Plugins/Base/Helper/RandomHelper.cs
Unity/Assets/Plugins/Base/Helper/RandomHelper.cs
+8
-0
Unity/Assets/Plugins/Base/Message/AMessage.cs
Unity/Assets/Plugins/Base/Message/AMessage.cs
+1
-1
Unity/Assets/Plugins/Base/Message/RpcException.cs
Unity/Assets/Plugins/Base/Message/RpcException.cs
+2
-2
Unity/Assets/Scripts/Component/MessageComponent.cs
Unity/Assets/Scripts/Component/MessageComponent.cs
+5
-5
Unity/Assets/Scripts/Message/ErrorCode.cs
Unity/Assets/Scripts/Message/ErrorCode.cs
+2
-0
Unity/Assets/Scripts/Message/Message.cs
Unity/Assets/Scripts/Message/Message.cs
+47
-10
Unity/Assets/Scripts/Other/CommandLine.cs
Unity/Assets/Scripts/Other/CommandLine.cs
+1
-1
Unity/Assets/Scripts/Other/CommandLine.cs.meta
Unity/Assets/Scripts/Other/CommandLine.cs.meta
+2
-2
Unity/Controller/Event/InitSceneStartEvent_InitGame.cs
Unity/Controller/Event/InitSceneStartEvent_InitGame.cs
+7
-3
Unity/Controller/Message/R2C_ServerLogHandler.cs
Unity/Controller/Message/R2C_ServerLogHandler.cs
+14
-0
Unity/Controller/Unity.Controller.csproj
Unity/Controller/Unity.Controller.csproj
+1
-1
Unity/Unity.CSharp.Editor.csproj
Unity/Unity.CSharp.Editor.csproj
+4
-3
Unity/Unity.CSharp.csproj
Unity/Unity.CSharp.csproj
+1
-0
未找到文件。
Server/App/Program.cs
浏览文件 @
fd0b276f
...
@@ -33,8 +33,10 @@ namespace App
...
@@ -33,8 +33,10 @@ namespace App
switch
(
options
.
AppType
)
switch
(
options
.
AppType
)
{
{
case
"Realm"
:
case
"Realm"
:
Game
.
Scene
.
AddComponent
<
RealmGateAddressComponent
>();
break
;
break
;
case
"Gate"
:
case
"Gate"
:
Game
.
Scene
.
AddComponent
<
GateSessionKeyComponent
>();
break
;
break
;
default
:
default
:
throw
new
Exception
(
$"命令行参数没有设置正确的AppType:
{
options
.
AppType
}
"
);
throw
new
Exception
(
$"命令行参数没有设置正确的AppType:
{
options
.
AppType
}
"
);
...
...
Server/Controller/C2S_SubscribeLogHandler.cs
已删除
100644 → 0
浏览文件 @
fe94aadc
using
System
;
using
Base
;
using
Model
;
namespace
Controller
{
[
MessageHandler
(
AppType
.
Realm
)]
public
class
C2S_SubscribeLogHandler
:
AMRpcEvent
<
C2S_SubscribeLog
,
S2C_SubscribeLog
>
{
protected
override
void
Run
(
Entity
entity
,
C2S_SubscribeLog
message
,
Action
<
S2C_SubscribeLog
>
reply
)
{
Log
.
Info
(
MongoHelper
.
ToJson
(
message
));
entity
.
AddComponent
<
LogToClientComponent
>();
reply
(
new
S2C_SubscribeLog
());
}
}
}
\ No newline at end of file
Server/Controller/Message/C2G_LoginGateHandler.cs
0 → 100644
浏览文件 @
fd0b276f
using
System
;
using
Base
;
using
Model
;
namespace
Controller
{
[
MessageHandler
(
AppType
.
Gate
)]
public
class
C2G_LoginGateHandler
:
AMRpcEvent
<
C2G_LoginGate
,
G2C_LoginGate
>
{
protected
override
void
Run
(
Entity
scene
,
C2G_LoginGate
message
,
Action
<
G2C_LoginGate
>
reply
)
{
bool
isCheckOK
=
Game
.
Scene
.
GetComponent
<
GateSessionKeyComponent
>().
Check
(
message
.
Key
);
G2C_LoginGate
g2CLoginGate
=
new
G2C_LoginGate
();
if
(!
isCheckOK
)
{
g2CLoginGate
.
Error
=
ErrorCode
.
ERR_ConnectGateKeyError
;
g2CLoginGate
.
Message
=
"Gate key验证失败!"
;
}
reply
(
g2CLoginGate
);
}
}
}
\ No newline at end of file
Server/Controller/Message/C2R_LoginHandler.cs
0 → 100644
浏览文件 @
fd0b276f
using
System
;
using
Base
;
using
Model
;
namespace
Controller
{
[
MessageHandler
(
AppType
.
Realm
)]
public
class
C2R_LoginHandler
:
AMRpcEvent
<
C2R_Login
,
R2C_Login
>
{
protected
override
async
void
Run
(
Entity
session
,
C2R_Login
message
,
Action
<
R2C_Login
>
reply
)
{
R2C_Login
r2CLogin
;
if
(
message
.
Account
!=
"abcdef"
||
message
.
Password
!=
"111111"
)
{
r2CLogin
=
new
R2C_Login
{
Error
=
ErrorCode
.
ERR_AccountOrPasswordError
,
Message
=
"账号名或者密码错误!"
};
reply
(
r2CLogin
);
return
;
}
// 随机分配一个Gate
string
gateAddress
=
Game
.
Scene
.
GetComponent
<
RealmGateAddressComponent
>().
GetAddress
();
Entity
gateSession
=
Game
.
Scene
.
GetComponent
<
NetworkComponent
>().
Get
(
gateAddress
);
// 向gate请求一个key,客户端可以拿着这个key连接gate
G2R_GetLoginKey
g2RGetLoginKey
=
await
gateSession
.
GetComponent
<
MessageComponent
>().
Call
<
R2G_GetLoginKey
,
G2R_GetLoginKey
>(
new
R2G_GetLoginKey
());
r2CLogin
=
new
R2C_Login
{
Address
=
gateAddress
,
Key
=
g2RGetLoginKey
.
Key
};
reply
(
r2CLogin
);
}
}
}
\ No newline at end of file
Server/Controller/
C2S_Login
Handler.cs
→
Server/Controller/
Message/C2R_SubscribeLog
Handler.cs
浏览文件 @
fd0b276f
...
@@ -5,13 +5,15 @@ using Model;
...
@@ -5,13 +5,15 @@ using Model;
namespace
Controller
namespace
Controller
{
{
[
MessageHandler
(
AppType
.
Realm
)]
[
MessageHandler
(
AppType
.
Realm
)]
public
class
C2
S_LoginHandler
:
AMRpcEvent
<
C2S_Login
,
S2C_Login
>
public
class
C2
R_SubscribeLogHandler
:
AMRpcEvent
<
C2R_SubscribeLog
,
R2C_SubscribeLog
>
{
{
protected
override
void
Run
(
Entity
scene
,
C2S_Login
message
,
Action
<
S2C_Login
>
reply
)
protected
override
void
Run
(
Entity
entity
,
C2R_SubscribeLog
message
,
Action
<
R2C_SubscribeLog
>
reply
)
{
{
Log
.
Info
(
MongoHelper
.
ToJson
(
message
));
Log
.
Info
(
MongoHelper
.
ToJson
(
message
));
reply
(
new
S2C_Login
());
//entity.AddComponent<LogToClientComponent>();
reply
(
new
R2C_SubscribeLog
());
}
}
}
}
}
}
\ No newline at end of file
Server/Controller/Message/R2G_GetLoginKeyHandler.cs
0 → 100644
浏览文件 @
fd0b276f
using
System
;
using
Base
;
using
Model
;
namespace
Controller
{
[
MessageHandler
(
AppType
.
Gate
)]
public
class
R2G_GetLoginKeyHandler
:
AMRpcEvent
<
R2G_GetLoginKey
,
G2R_GetLoginKey
>
{
protected
override
void
Run
(
Entity
scene
,
R2G_GetLoginKey
message
,
Action
<
G2R_GetLoginKey
>
reply
)
{
long
key
=
Game
.
Scene
.
GetComponent
<
GateSessionKeyComponent
>().
Get
();
G2R_GetLoginKey
g2RGetLoginKey
=
new
G2R_GetLoginKey
(
key
);
reply
(
g2RGetLoginKey
);
}
}
}
\ No newline at end of file
Server/Controller/Server.Controller.csproj
浏览文件 @
fd0b276f
...
@@ -34,9 +34,11 @@
...
@@ -34,9 +34,11 @@
<Reference
Include=
"System.Core"
/>
<Reference
Include=
"System.Core"
/>
</ItemGroup>
</ItemGroup>
<ItemGroup>
<ItemGroup>
<Compile
Include=
"C2S_SubscribeLogHandler.cs"
/>
<Compile
Include=
"Message\C2G_LoginGateHandler.cs"
/>
<Compile
Include=
"Message\R2G_GetLoginKeyHandler.cs"
/>
<Compile
Include=
"Message\C2R_SubscribeLogHandler.cs"
/>
<Compile
Include=
"Properties\AssemblyInfo.cs"
/>
<Compile
Include=
"Properties\AssemblyInfo.cs"
/>
<Compile
Include=
"
C2S
_LoginHandler.cs"
/>
<Compile
Include=
"
Message\C2R
_LoginHandler.cs"
/>
</ItemGroup>
</ItemGroup>
<ItemGroup>
<ItemGroup>
<ProjectReference
Include=
"..\Base\Server.Base.csproj"
>
<ProjectReference
Include=
"..\Base\Server.Base.csproj"
>
...
...
Server/Model/Component/GateSessionKeyComponent.cs
0 → 100644
浏览文件 @
fd0b276f
using
System.Collections.Generic
;
using
Base
;
namespace
Model
{
[
ObjectEvent
]
public
class
GateSessionKeyComponentEvent
:
ObjectEvent
<
GateSessionKeyComponent
>,
IAwake
{
public
void
Awake
()
{
this
.
GetValue
().
Awake
();
}
}
public
class
GateSessionKeyComponent
:
Component
{
private
TimerComponent
timerComponent
;
private
readonly
HashSet
<
long
>
sessionKey
=
new
HashSet
<
long
>();
public
void
Awake
()
{
this
.
timerComponent
=
Game
.
Scene
.
GetComponent
<
TimerComponent
>();
}
public
long
Get
()
{
long
key
=
RandomHelper
.
RandInt64
();
this
.
sessionKey
.
Add
(
key
);
this
.
TimeoutRemoveKey
(
key
);
return
key
;
}
public
bool
Check
(
long
key
)
{
bool
ret
=
this
.
sessionKey
.
Contains
(
key
);
if
(
ret
)
{
this
.
sessionKey
.
Remove
(
key
);
}
return
ret
;
}
public
void
Remove
(
long
key
)
{
this
.
sessionKey
.
Remove
(
key
);
}
private
async
void
TimeoutRemoveKey
(
long
key
)
{
await
this
.
timerComponent
.
WaitAsync
(
20000
);
this
.
sessionKey
.
Remove
(
key
);
}
}
}
Server/Model/Component/LogToClientComponent.cs
浏览文件 @
fd0b276f
...
@@ -14,10 +14,12 @@ namespace Model
...
@@ -14,10 +14,12 @@ namespace Model
public
class
LogToClientComponent
:
Component
public
class
LogToClientComponent
:
Component
{
{
private
string
appType
;
private
string
appType
;
private
int
appId
;
public
void
Awake
()
public
void
Awake
()
{
{
this
.
appType
=
Game
.
Scene
.
GetComponent
<
OptionsComponent
>().
Options
.
AppType
;
this
.
appType
=
Game
.
Scene
.
GetComponent
<
OptionsComponent
>().
Options
.
AppType
;
this
.
appId
=
Game
.
Scene
.
GetComponent
<
OptionsComponent
>().
Options
.
Id
;
Log
.
Callback
.
Add
(
this
.
Id
,
this
.
LogToClient
);
Log
.
Callback
.
Add
(
this
.
Id
,
this
.
LogToClient
);
}
}
...
@@ -27,7 +29,7 @@ namespace Model
...
@@ -27,7 +29,7 @@ namespace Model
{
{
return
;
return
;
}
}
this
.
GetComponent
<
MessageComponent
>().
Send
(
new
S2C_ServerLog
{
AppType
=
this
.
appType
,
Type
=
type
,
Log
=
message
});
this
.
GetComponent
<
MessageComponent
>().
Send
(
new
R2C_ServerLog
{
AppType
=
this
.
appType
,
AppId
=
this
.
appId
,
Type
=
type
,
Log
=
message
});
}
}
public
override
void
Dispose
()
public
override
void
Dispose
()
...
...
Server/Model/Component/RealmGateAddressComponent.cs
0 → 100644
浏览文件 @
fd0b276f
using
System
;
using
System.Collections.Generic
;
using
System.IO
;
using
Base
;
namespace
Model
{
[
ObjectEvent
]
public
class
RealmGateAddressComponentEvent
:
ObjectEvent
<
RealmGateAddressComponent
>,
IAwake
{
public
void
Awake
()
{
this
.
GetValue
().
Awake
();
}
}
public
class
RealmGateAddressComponent
:
Component
{
private
readonly
List
<
string
>
GateAddress
=
new
List
<
string
>();
public
void
Awake
()
{
string
s
=
File
.
ReadAllText
(
"./CommandLineConfig.txt"
);
CommandLines
commandLines
=
MongoHelper
.
FromJson
<
CommandLines
>(
s
);
foreach
(
CommandLine
commandLine
in
commandLines
.
Commands
)
{
if
(
commandLine
.
Options
.
AppType
!=
"Gate"
)
{
continue
;
}
this
.
GateAddress
.
Add
(
$"
{
commandLine
.
Options
.
Host
}
:
{
commandLine
.
Options
.
Port
}
"
);
}
}
public
string
GetAddress
()
{
int
n
=
RandomHelper
.
RandomNumber
(
0
,
this
.
GateAddress
.
Count
);
return
this
.
GateAddress
[
n
];
}
}
}
Server/Model/Server.Model.csproj
浏览文件 @
fd0b276f
...
@@ -74,10 +74,15 @@
...
@@ -74,10 +74,15 @@
<Compile
Include=
"..\..\Unity\Assets\Scripts\Message\OpcodeHelper.cs"
>
<Compile
Include=
"..\..\Unity\Assets\Scripts\Message\OpcodeHelper.cs"
>
<Link>
Message\OpcodeHelper.cs
</Link>
<Link>
Message\OpcodeHelper.cs
</Link>
</Compile>
</Compile>
<Compile
Include=
"..\..\Unity\Assets\Scripts\Other\CommandLine.cs"
>
<Link>
Other\CommandLine.cs
</Link>
</Compile>
<Compile
Include=
"..\..\Unity\Assets\Scripts\Other\Options.cs"
>
<Compile
Include=
"..\..\Unity\Assets\Scripts\Other\Options.cs"
>
<Link>
Other\Options.cs
</Link>
<Link>
Other\Options.cs
</Link>
</Compile>
</Compile>
<Compile
Include=
"Component\LogToClientComponent.cs"
/>
<Compile
Include=
"Component\LogToClientComponent.cs"
/>
<Compile
Include=
"Component\GateSessionKeyComponent.cs"
/>
<Compile
Include=
"Component\RealmGateAddressComponent.cs"
/>
<Compile
Include=
"Component\OptionsComponent.cs"
/>
<Compile
Include=
"Component\OptionsComponent.cs"
/>
<Compile
Include=
"Properties\AssemblyInfo.cs"
/>
<Compile
Include=
"Properties\AssemblyInfo.cs"
/>
</ItemGroup>
</ItemGroup>
...
...
Unity/Assets/Editor/ServerCommandLineEditor/UI/ServerCommandLineEditor.cs
浏览文件 @
fd0b276f
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
using
System.Diagnostics
;
using
System.Diagnostics
;
using
System.IO
;
using
System.IO
;
using
Base
;
using
Base
;
using
Model
;
using
UnityEditor
;
using
UnityEditor
;
using
UnityEngine
;
using
UnityEngine
;
...
...
Unity/Assets/Plugins/Base/Helper/RandomHelper.cs
浏览文件 @
fd0b276f
...
@@ -12,6 +12,14 @@ namespace Base
...
@@ -12,6 +12,14 @@ namespace Base
return
BitConverter
.
ToUInt64
(
bytes
,
0
);
return
BitConverter
.
ToUInt64
(
bytes
,
0
);
}
}
public
static
Int64
RandInt64
()
{
var
bytes
=
new
byte
[
8
];
Random
random
=
new
Random
();
random
.
NextBytes
(
bytes
);
return
BitConverter
.
ToInt64
(
bytes
,
0
);
}
/// <summary>
/// <summary>
/// 获取lower与Upper之间的随机数
/// 获取lower与Upper之间的随机数
/// </summary>
/// </summary>
...
...
Unity/Assets/Plugins/Base/Message/AMessage.cs
浏览文件 @
fd0b276f
...
@@ -13,7 +13,7 @@
...
@@ -13,7 +13,7 @@
/// </summary>
/// </summary>
public
abstract
class
AResponse
:
AMessage
public
abstract
class
AResponse
:
AMessage
{
{
public
int
Error
Code
=
0
;
public
int
Error
=
0
;
public
string
Message
=
""
;
public
string
Message
=
""
;
}
}
}
}
Unity/Assets/Plugins/Base/Message/RpcException.cs
浏览文件 @
fd0b276f
...
@@ -10,12 +10,12 @@ namespace Base
...
@@ -10,12 +10,12 @@ namespace Base
{
{
public
int
Error
{
get
;
private
set
;
}
public
int
Error
{
get
;
private
set
;
}
public
RpcException
(
int
error
,
string
message
)
:
base
(
$"
{
error
}
:
{
message
}
"
)
public
RpcException
(
int
error
,
string
message
)
:
base
(
$"
Error:
{
error
}
Message
:
{
message
}
"
)
{
{
this
.
Error
=
error
;
this
.
Error
=
error
;
}
}
public
RpcException
(
int
error
,
string
message
,
Exception
e
)
:
base
(
$"
{
error
}
:
{
message
}
"
,
e
)
public
RpcException
(
int
error
,
string
message
,
Exception
e
)
:
base
(
$"
Error:
{
error
}
Message
:
{
message
}
"
,
e
)
{
{
this
.
Error
=
error
;
this
.
Error
=
error
;
}
}
...
...
Unity/Assets/Scripts/Component/MessageComponent.cs
浏览文件 @
fd0b276f
...
@@ -140,9 +140,9 @@ namespace Model
...
@@ -140,9 +140,9 @@ namespace Model
try
try
{
{
Response
response
=
MongoHelper
.
FromBson
<
Response
>(
bytes
,
offset
,
count
);
Response
response
=
MongoHelper
.
FromBson
<
Response
>(
bytes
,
offset
,
count
);
if
(
response
.
Error
Code
!=
0
)
if
(
response
.
Error
!=
0
)
{
{
tcs
.
SetException
(
new
RpcException
(
response
.
Error
Code
,
response
.
Message
));
tcs
.
SetException
(
new
RpcException
(
response
.
Error
,
response
.
Message
));
return
;
return
;
}
}
tcs
.
SetResult
(
response
);
tcs
.
SetResult
(
response
);
...
@@ -172,9 +172,9 @@ namespace Model
...
@@ -172,9 +172,9 @@ namespace Model
try
try
{
{
Response
response
=
MongoHelper
.
FromBson
<
Response
>(
bytes
,
offset
,
count
);
Response
response
=
MongoHelper
.
FromBson
<
Response
>(
bytes
,
offset
,
count
);
if
(
response
.
Error
Code
!=
0
)
if
(
response
.
Error
!=
0
)
{
{
tcs
.
SetException
(
new
RpcException
(
response
.
Error
Code
,
response
.
Message
));
tcs
.
SetException
(
new
RpcException
(
response
.
Error
,
response
.
Message
));
return
;
return
;
}
}
tcs
.
SetResult
(
response
);
tcs
.
SetResult
(
response
);
...
@@ -219,7 +219,7 @@ namespace Model
...
@@ -219,7 +219,7 @@ namespace Model
}
}
byte
[]
seqBytes
=
BitConverter
.
GetBytes
(
rpcId
);
byte
[]
seqBytes
=
BitConverter
.
GetBytes
(
rpcId
);
channel
.
Send
(
new
List
<
byte
[
]>
{
opcodeBytes
,
seqBytes
,
messageBytes
});
channel
.
Send
(
new
List
<
byte
[
]>
{
opcodeBytes
,
seqBytes
,
messageBytes
});
}
}
...
...
Unity/Assets/Scripts/Message/ErrorCode.cs
浏览文件 @
fd0b276f
...
@@ -3,5 +3,7 @@ namespace Model
...
@@ -3,5 +3,7 @@ namespace Model
public
static
class
ErrorCode
public
static
class
ErrorCode
{
{
public
const
int
ERR_Success
=
0
;
public
const
int
ERR_Success
=
0
;
public
const
int
ERR_AccountOrPasswordError
=
1
;
public
const
int
ERR_ConnectGateKeyError
=
2
;
}
}
}
}
Unity/Assets/Scripts/Message/Message.cs
浏览文件 @
fd0b276f
...
@@ -5,7 +5,7 @@ namespace Model
...
@@ -5,7 +5,7 @@ namespace Model
{
{
[
Message
(
1
)]
[
Message
(
1
)]
[
BsonIgnoreExtraElements
]
[
BsonIgnoreExtraElements
]
public
class
C2
S
_Login
:
ARequest
public
class
C2
R
_Login
:
ARequest
{
{
public
string
Account
;
public
string
Account
;
public
string
Password
;
public
string
Password
;
...
@@ -13,30 +13,67 @@ namespace Model
...
@@ -13,30 +13,67 @@ namespace Model
[
Message
(
2
)]
[
Message
(
2
)]
[
BsonIgnoreExtraElements
]
[
BsonIgnoreExtraElements
]
public
class
S
2C_Login
:
AResponse
public
class
R
2C_Login
:
AResponse
{
{
public
string
Host
;
public
string
Address
{
get
;
set
;
}
public
int
Port
;
public
long
Key
{
get
;
set
;
}
}
}
[
Message
(
3
)]
[
Message
(
3
)]
[
BsonIgnoreExtraElements
]
[
BsonIgnoreExtraElements
]
public
class
S
2C_ServerLog
:
AMessage
public
class
R
2C_ServerLog
:
AMessage
{
{
public
string
AppType
;
public
string
AppType
{
get
;
set
;
}
public
LogType
Type
;
public
int
AppId
{
get
;
set
;
}
public
string
Log
;
public
LogType
Type
{
get
;
set
;
}
public
string
Log
{
get
;
set
;
}
}
}
[
Message
(
4
)]
[
Message
(
4
)]
[
BsonIgnoreExtraElements
]
[
BsonIgnoreExtraElements
]
public
class
C2
S
_SubscribeLog
:
ARequest
public
class
C2
R
_SubscribeLog
:
ARequest
{
{
}
}
[
Message
(
5
)]
[
Message
(
5
)]
[
BsonIgnoreExtraElements
]
[
BsonIgnoreExtraElements
]
public
class
S2C_SubscribeLog
:
AResponse
public
class
R2C_SubscribeLog
:
AResponse
{
}
[
Message
(
6
)]
[
BsonIgnoreExtraElements
]
public
class
R2G_GetLoginKey
:
ARequest
{
}
[
Message
(
7
)]
[
BsonIgnoreExtraElements
]
public
class
G2R_GetLoginKey
:
AResponse
{
public
long
Key
;
public
G2R_GetLoginKey
(
long
key
)
{
this
.
Key
=
key
;
}
}
[
Message
(
8
)]
[
BsonIgnoreExtraElements
]
public
class
C2G_LoginGate
:
ARequest
{
public
long
Key
;
public
C2G_LoginGate
(
long
key
)
{
this
.
Key
=
key
;
}
}
[
Message
(
9
)]
[
BsonIgnoreExtraElements
]
public
class
G2C_LoginGate
:
AResponse
{
{
}
}
}
}
Unity/Assets/
Editor/ServerCommandLineEditor/Component
/CommandLine.cs
→
Unity/Assets/
Scripts/Other
/CommandLine.cs
浏览文件 @
fd0b276f
...
@@ -3,7 +3,7 @@ using System.Collections.Generic;
...
@@ -3,7 +3,7 @@ using System.Collections.Generic;
using
Base
;
using
Base
;
using
Model
;
using
Model
;
namespace
M
yEditor
namespace
M
odel
{
{
public
class
CommandLine
:
ICloneable
public
class
CommandLine
:
ICloneable
{
{
...
...
Unity/Assets/
Editor/ServerCommandLineEditor/Component
/CommandLine.cs.meta
→
Unity/Assets/
Scripts/Other
/CommandLine.cs.meta
浏览文件 @
fd0b276f
fileFormatVersion: 2
fileFormatVersion: 2
guid:
4f4981289b5c3cc4ca1604a6ba39f3a8
guid:
c181dc38f15288746960812611a7767e
timeCreated: 1476
674012
timeCreated: 1476
862821
licenseType: Pro
licenseType: Pro
MonoImporter:
MonoImporter:
serializedVersion: 2
serializedVersion: 2
...
...
Unity/Controller/Event/InitSceneStartEvent_InitGame.cs
浏览文件 @
fd0b276f
...
@@ -19,9 +19,13 @@ namespace Controller
...
@@ -19,9 +19,13 @@ namespace Controller
try
try
{
{
// 订阅服务端日志, 服务端收到这个消息会将之后的日志转发给客户端
// 订阅服务端日志, 服务端收到这个消息会将之后的日志转发给客户端
await
session
.
GetComponent
<
MessageComponent
>().
Call
<
C2S_SubscribeLog
,
S2C_SubscribeLog
>(
new
C2S_SubscribeLog
());
await
session
.
GetComponent
<
MessageComponent
>().
Call
<
C2R_SubscribeLog
,
R2C_SubscribeLog
>(
new
C2R_SubscribeLog
());
S2C_Login
s2CLogin
=
await
session
.
GetComponent
<
MessageComponent
>().
Call
<
C2S_Login
,
S2C_Login
>(
new
C2S_Login
{
Account
=
"tanghai"
,
Password
=
"1111111"
});
R2C_Login
s2CLogin
=
await
session
.
GetComponent
<
MessageComponent
>().
Call
<
C2R_Login
,
R2C_Login
>(
new
C2R_Login
{
Account
=
"111"
,
Password
=
"111111"
});
Log
.
Info
(
MongoHelper
.
ToJson
(
s2CLogin
));
// 连接Gate
Entity
gateSession
=
networkComponent
.
Get
(
s2CLogin
.
Address
);
await
gateSession
.
GetComponent
<
MessageComponent
>().
Call
<
C2G_LoginGate
,
G2C_LoginGate
>(
new
C2G_LoginGate
(
s2CLogin
.
Key
));
Log
.
Info
(
"连接Gate验证成功!"
);
}
}
catch
(
RpcException
e
)
catch
(
RpcException
e
)
{
{
...
...
Unity/Controller/Message/
S
2C_ServerLogHandler.cs
→
Unity/Controller/Message/
R
2C_ServerLogHandler.cs
浏览文件 @
fd0b276f
...
@@ -4,11 +4,11 @@ using Model;
...
@@ -4,11 +4,11 @@ using Model;
namespace
Controller
namespace
Controller
{
{
[
MessageHandler
(
AppType
.
Client
)]
[
MessageHandler
(
AppType
.
Client
)]
public
class
S2C_ServerLogHandler
:
AMEvent
<
S
2C_ServerLog
>
public
class
R2C_ServerLogHandler
:
AMEvent
<
R
2C_ServerLog
>
{
{
protected
override
void
Run
(
Entity
scene
,
S
2C_ServerLog
message
)
protected
override
void
Run
(
Entity
scene
,
R
2C_ServerLog
message
)
{
{
Log
.
Debug
(
$"[
{
message
.
AppType
}
] [
{
message
.
Type
}
]
{
message
.
Log
}
"
);
Log
.
Debug
(
$"[
{
message
.
AppType
}
]
[
{
message
.
AppId
}
]
[
{
message
.
Type
}
]
{
message
.
Log
}
"
);
}
}
}
}
}
}
Unity/Controller/Unity.Controller.csproj
浏览文件 @
fd0b276f
...
@@ -54,7 +54,7 @@
...
@@ -54,7 +54,7 @@
</ItemGroup>
</ItemGroup>
<ItemGroup>
<ItemGroup>
<Compile
Include=
"Event\InitSceneStartEvent_InitGame.cs"
/>
<Compile
Include=
"Event\InitSceneStartEvent_InitGame.cs"
/>
<Compile
Include=
"Message\
S
2C_ServerLogHandler.cs"
/>
<Compile
Include=
"Message\
R
2C_ServerLogHandler.cs"
/>
<Compile
Include=
"Properties\AssemblyInfo.cs"
/>
<Compile
Include=
"Properties\AssemblyInfo.cs"
/>
</ItemGroup>
</ItemGroup>
<ItemGroup>
<ItemGroup>
...
...
Unity/Unity.CSharp.Editor.csproj
浏览文件 @
fd0b276f
...
@@ -13,11 +13,13 @@
...
@@ -13,11 +13,13 @@
<TargetFrameworkIdentifier>
.NETFramework
</TargetFrameworkIdentifier>
<TargetFrameworkIdentifier>
.NETFramework
</TargetFrameworkIdentifier>
<TargetFrameworkVersion>
v3.5
</TargetFrameworkVersion>
<TargetFrameworkVersion>
v3.5
</TargetFrameworkVersion>
<TargetFrameworkProfile>
Unity Full v3.5
</TargetFrameworkProfile>
<TargetFrameworkProfile>
Unity Full v3.5
</TargetFrameworkProfile>
<CompilerResponseFile></CompilerResponseFile>
<CompilerResponseFile>
</CompilerResponseFile>
<UnityProjectType>
Editor:5
</UnityProjectType>
<UnityProjectType>
Editor:5
</UnityProjectType>
<UnityBuildTarget>
StandaloneWindows:5
</UnityBuildTarget>
<UnityBuildTarget>
StandaloneWindows:5
</UnityBuildTarget>
<UnityVersion>
5.4.2f1
</UnityVersion>
<UnityVersion>
5.4.2f1
</UnityVersion>
<RootNamespace></RootNamespace>
<RootNamespace>
</RootNamespace>
</PropertyGroup>
</PropertyGroup>
<PropertyGroup
Condition=
" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "
>
<PropertyGroup
Condition=
" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "
>
<DebugType>
pdbonly
</DebugType>
<DebugType>
pdbonly
</DebugType>
...
@@ -112,7 +114,6 @@
...
@@ -112,7 +114,6 @@
</ItemGroup>
</ItemGroup>
<ItemGroup>
<ItemGroup>
<Compile
Include=
"Assets\Editor\ReferenceCollectorEditor\ReferenceCollectorEditor.cs"
/>
<Compile
Include=
"Assets\Editor\ReferenceCollectorEditor\ReferenceCollectorEditor.cs"
/>
<Compile
Include=
"Assets\Editor\ServerCommandLineEditor\Component\CommandLine.cs"
/>
<Compile
Include=
"Assets\Editor\ServerCommandLineEditor\UI\ServerCommandLineEditor.cs"
/>
<Compile
Include=
"Assets\Editor\ServerCommandLineEditor\UI\ServerCommandLineEditor.cs"
/>
</ItemGroup>
</ItemGroup>
<ItemGroup>
<ItemGroup>
...
...
Unity/Unity.CSharp.csproj
浏览文件 @
fd0b276f
...
@@ -102,6 +102,7 @@
...
@@ -102,6 +102,7 @@
<Compile
Include=
"Assets\Scripts\Message\ErrorCode.cs"
/>
<Compile
Include=
"Assets\Scripts\Message\ErrorCode.cs"
/>
<Compile
Include=
"Assets\Scripts\Message\Message.cs"
/>
<Compile
Include=
"Assets\Scripts\Message\Message.cs"
/>
<Compile
Include=
"Assets\Scripts\Message\OpcodeHelper.cs"
/>
<Compile
Include=
"Assets\Scripts\Message\OpcodeHelper.cs"
/>
<Compile
Include=
"Assets\Scripts\Other\CommandLine.cs"
/>
<Compile
Include=
"Assets\Scripts\Other\EntityType.cs"
/>
<Compile
Include=
"Assets\Scripts\Other\EntityType.cs"
/>
<Compile
Include=
"Assets\Scripts\Other\GameException.cs"
/>
<Compile
Include=
"Assets\Scripts\Other\GameException.cs"
/>
<Compile
Include=
"Assets\Scripts\Other\Options.cs"
/>
<Compile
Include=
"Assets\Scripts\Other\Options.cs"
/>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录