mirror of
https://github.com/Alex-Rachel/TEngine.git
synced 2025-08-14 16:51:28 +00:00
Update Demo
Update Demo
This commit is contained in:
@@ -4,12 +4,18 @@ namespace GameLogic
|
|||||||
{
|
{
|
||||||
public class NetworkUtils
|
public class NetworkUtils
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 网络消息校验错误码。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="response">网络回复消息包。</param>
|
||||||
|
/// <returns>是否存在错误。</returns>
|
||||||
public static bool CheckError(IResponse response)
|
public static bool CheckError(IResponse response)
|
||||||
{
|
{
|
||||||
bool hasError = false;
|
bool hasError = false;
|
||||||
if (response == null)
|
if (response == null)
|
||||||
{
|
{
|
||||||
var networkError = "NetWork Response Error";
|
// TODO 根据错误码Tips提示。
|
||||||
|
// var networkError = "NetWork Response Error";
|
||||||
hasError = true;
|
hasError = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@@ -10,12 +10,20 @@ namespace GameLogic
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class PlayerNetSys:DataCenterModule<PlayerNetSys>
|
public class PlayerNetSys:DataCenterModule<PlayerNetSys>
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 网络模块初始化。
|
||||||
|
/// </summary>
|
||||||
public override void Init()
|
public override void Init()
|
||||||
{
|
{
|
||||||
base.Init();
|
base.Init();
|
||||||
|
//注册登录消息回调。
|
||||||
GameClient.Instance.RegisterMsgHandler(OuterOpcode.H_G2C_LoginResponse,OnLoginRes);
|
GameClient.Instance.RegisterMsgHandler(OuterOpcode.H_G2C_LoginResponse,OnLoginRes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 登录消息回调。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="response">网络回复消息包。</param>
|
||||||
public void OnLoginRes(IResponse response)
|
public void OnLoginRes(IResponse response)
|
||||||
{
|
{
|
||||||
if (NetworkUtils.CheckError(response))
|
if (NetworkUtils.CheckError(response))
|
||||||
@@ -28,6 +36,11 @@ namespace GameLogic
|
|||||||
GameClient.Instance.Status = GameClientStatus.StatusEnter;
|
GameClient.Instance.Status = GameClientStatus.StatusEnter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 登录消息请求。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="userName">用户名。</param>
|
||||||
|
/// <param name="passWord">用户密码。</param>
|
||||||
public void DoLoginReq(string userName,string passWord)
|
public void DoLoginReq(string userName,string passWord)
|
||||||
{
|
{
|
||||||
if (GameClient.Instance.Status == GameClientStatus.StatusEnter)
|
if (GameClient.Instance.Status == GameClientStatus.StatusEnter)
|
||||||
|
Reference in New Issue
Block a user